2003-01-11 04:58:36 +00:00
|
|
|
/*
|
2014-05-03 09:04:50 +00:00
|
|
|
* YUV4MPEG demuxer
|
2009-01-19 15:46:40 +00:00
|
|
|
* Copyright (c) 2001, 2002, 2003 Fabrice Bellard
|
2003-01-11 04:58:36 +00:00
|
|
|
*
|
2011-03-18 17:35:10 +00:00
|
|
|
* This file is part of Libav.
|
2006-10-07 15:30:46 +00:00
|
|
|
*
|
2011-03-18 17:35:10 +00:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2003-01-11 04:58:36 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 15:30:46 +00:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2003-01-11 04:58:36 +00:00
|
|
|
*
|
2011-03-18 17:35:10 +00:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2003-01-11 04:58:36 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2011-03-18 17:35:10 +00:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2006-01-12 22:43:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-01-11 04:58:36 +00:00
|
|
|
*/
|
2013-01-09 19:50:06 +00:00
|
|
|
|
2015-10-14 09:33:24 +00:00
|
|
|
#include "libavutil/imgutils.h"
|
|
|
|
|
2003-01-11 04:58:36 +00:00
|
|
|
#include "avformat.h"
|
2011-11-29 18:28:15 +00:00
|
|
|
#include "internal.h"
|
2014-05-03 09:04:50 +00:00
|
|
|
#include "yuv4mpeg.h"
|
2003-01-11 04:58:36 +00:00
|
|
|
|
2014-05-03 09:04:50 +00:00
|
|
|
/* Header size increased to allow room for optional flags */
|
|
|
|
#define MAX_YUV4_HEADER 80
|
|
|
|
#define MAX_FRAME_HEADER 80
|
2003-01-11 04:58:36 +00:00
|
|
|
|
2012-01-12 12:20:36 +00:00
|
|
|
static int yuv4_read_header(AVFormatContext *s)
|
2003-08-05 09:32:31 +00:00
|
|
|
{
|
2011-11-30 11:16:07 +00:00
|
|
|
char header[MAX_YUV4_HEADER + 10]; // Include headroom for
|
|
|
|
// the longest option
|
|
|
|
char *tokstart, *tokend, *header_end;
|
2003-08-05 09:32:31 +00:00
|
|
|
int i;
|
2011-02-20 10:04:12 +00:00
|
|
|
AVIOContext *pb = s->pb;
|
2011-11-30 11:16:07 +00:00
|
|
|
int width = -1, height = -1, raten = 0,
|
|
|
|
rated = 0, aspectn = 0, aspectd = 0;
|
2012-10-06 10:10:34 +00:00
|
|
|
enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE, alt_pix_fmt = AV_PIX_FMT_NONE;
|
2009-05-11 04:35:15 +00:00
|
|
|
enum AVChromaLocation chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED;
|
2015-01-28 14:41:00 +00:00
|
|
|
enum AVFieldOrder field_order = AV_FIELD_UNKNOWN;
|
2003-08-05 09:32:31 +00:00
|
|
|
AVStream *st;
|
2005-12-17 18:14:38 +00:00
|
|
|
|
2011-11-30 11:16:07 +00:00
|
|
|
for (i = 0; i < MAX_YUV4_HEADER; i++) {
|
2011-02-21 15:43:01 +00:00
|
|
|
header[i] = avio_r8(pb);
|
2005-12-22 01:10:11 +00:00
|
|
|
if (header[i] == '\n') {
|
2011-11-30 11:16:07 +00:00
|
|
|
header[i + 1] = 0x20; // Add a space after last option.
|
|
|
|
// Makes parsing "444" vs "444alpha" easier.
|
|
|
|
header[i + 2] = 0;
|
2005-12-22 01:10:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-08-05 09:32:31 +00:00
|
|
|
}
|
2011-11-30 11:16:07 +00:00
|
|
|
if (i == MAX_YUV4_HEADER)
|
|
|
|
return -1;
|
|
|
|
if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC)))
|
|
|
|
return -1;
|
2005-01-04 01:55:50 +00:00
|
|
|
|
2011-11-30 11:16:07 +00:00
|
|
|
header_end = &header[i + 1]; // Include space
|
|
|
|
for (tokstart = &header[strlen(Y4M_MAGIC) + 1];
|
|
|
|
tokstart < header_end; tokstart++) {
|
|
|
|
if (*tokstart == 0x20)
|
|
|
|
continue;
|
2005-01-04 01:55:50 +00:00
|
|
|
switch (*tokstart++) {
|
|
|
|
case 'W': // Width. Required.
|
2011-11-30 11:16:07 +00:00
|
|
|
width = strtol(tokstart, &tokend, 10);
|
|
|
|
tokstart = tokend;
|
2005-01-04 01:55:50 +00:00
|
|
|
break;
|
|
|
|
case 'H': // Height. Required.
|
2011-11-30 11:16:07 +00:00
|
|
|
height = strtol(tokstart, &tokend, 10);
|
|
|
|
tokstart = tokend;
|
2005-01-04 01:55:50 +00:00
|
|
|
break;
|
|
|
|
case 'C': // Color space
|
2011-11-30 11:16:07 +00:00
|
|
|
if (strncmp("420jpeg", tokstart, 7) == 0) {
|
2012-10-06 10:10:34 +00:00
|
|
|
pix_fmt = AV_PIX_FMT_YUV420P;
|
2009-05-11 04:35:15 +00:00
|
|
|
chroma_sample_location = AVCHROMA_LOC_CENTER;
|
2011-11-30 11:16:07 +00:00
|
|
|
} else if (strncmp("420mpeg2", tokstart, 8) == 0) {
|
2012-10-06 10:10:34 +00:00
|
|
|
pix_fmt = AV_PIX_FMT_YUV420P;
|
2009-05-11 04:35:15 +00:00
|
|
|
chroma_sample_location = AVCHROMA_LOC_LEFT;
|
2011-11-30 11:16:07 +00:00
|
|
|
} else if (strncmp("420paldv", tokstart, 8) == 0) {
|
2012-10-06 10:10:34 +00:00
|
|
|
pix_fmt = AV_PIX_FMT_YUV420P;
|
2009-05-11 04:35:15 +00:00
|
|
|
chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
|
2012-01-30 05:24:41 +00:00
|
|
|
} else if (strncmp("420", tokstart, 3) == 0) {
|
2012-10-06 10:10:34 +00:00
|
|
|
pix_fmt = AV_PIX_FMT_YUV420P;
|
2012-01-30 05:24:41 +00:00
|
|
|
chroma_sample_location = AVCHROMA_LOC_CENTER;
|
2011-11-30 11:16:07 +00:00
|
|
|
} else if (strncmp("411", tokstart, 3) == 0)
|
2012-10-06 10:10:34 +00:00
|
|
|
pix_fmt = AV_PIX_FMT_YUV411P;
|
2011-11-30 11:16:07 +00:00
|
|
|
else if (strncmp("422", tokstart, 3) == 0)
|
2012-10-06 10:10:34 +00:00
|
|
|
pix_fmt = AV_PIX_FMT_YUV422P;
|
2011-11-30 11:16:07 +00:00
|
|
|
else if (strncmp("444alpha", tokstart, 8) == 0 ) {
|
|
|
|
av_log(s, AV_LOG_ERROR, "Cannot handle 4:4:4:4 "
|
|
|
|
"YUV4MPEG stream.\n");
|
2005-01-04 01:55:50 +00:00
|
|
|
return -1;
|
2011-11-30 11:16:07 +00:00
|
|
|
} else if (strncmp("444", tokstart, 3) == 0)
|
2012-10-06 10:10:34 +00:00
|
|
|
pix_fmt = AV_PIX_FMT_YUV444P;
|
2011-11-30 11:16:07 +00:00
|
|
|
else if (strncmp("mono", tokstart, 4) == 0) {
|
2012-10-06 10:10:34 +00:00
|
|
|
pix_fmt = AV_PIX_FMT_GRAY8;
|
2005-01-04 01:55:50 +00:00
|
|
|
} else {
|
2011-11-30 11:16:07 +00:00
|
|
|
av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains an unknown "
|
|
|
|
"pixel format.\n");
|
2005-01-04 01:55:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2011-11-30 11:16:07 +00:00
|
|
|
while (tokstart < header_end && *tokstart != 0x20)
|
|
|
|
tokstart++;
|
2005-01-04 01:55:50 +00:00
|
|
|
break;
|
|
|
|
case 'I': // Interlace type
|
|
|
|
switch (*tokstart++){
|
|
|
|
case '?':
|
2014-05-03 09:08:25 +00:00
|
|
|
field_order = AV_FIELD_UNKNOWN;
|
2005-01-04 01:55:50 +00:00
|
|
|
break;
|
|
|
|
case 'p':
|
2014-05-03 09:08:25 +00:00
|
|
|
field_order = AV_FIELD_PROGRESSIVE;
|
2005-01-04 01:55:50 +00:00
|
|
|
break;
|
|
|
|
case 't':
|
2014-05-03 09:08:25 +00:00
|
|
|
field_order = AV_FIELD_TT;
|
2005-01-04 01:55:50 +00:00
|
|
|
break;
|
|
|
|
case 'b':
|
2014-05-03 09:08:25 +00:00
|
|
|
field_order = AV_FIELD_BB;
|
2005-01-04 01:55:50 +00:00
|
|
|
break;
|
|
|
|
case 'm':
|
2011-11-30 11:16:07 +00:00
|
|
|
av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed "
|
|
|
|
"interlaced and non-interlaced frames.\n");
|
2005-01-04 01:55:50 +00:00
|
|
|
return -1;
|
|
|
|
default:
|
|
|
|
av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'F': // Frame rate
|
2011-11-30 11:16:07 +00:00
|
|
|
sscanf(tokstart, "%d:%d", &raten, &rated); // 0:0 if unknown
|
|
|
|
while (tokstart < header_end && *tokstart != 0x20)
|
|
|
|
tokstart++;
|
2005-01-04 01:55:50 +00:00
|
|
|
break;
|
|
|
|
case 'A': // Pixel aspect
|
2011-11-30 11:16:07 +00:00
|
|
|
sscanf(tokstart, "%d:%d", &aspectn, &aspectd); // 0:0 if unknown
|
|
|
|
while (tokstart < header_end && *tokstart != 0x20)
|
|
|
|
tokstart++;
|
2005-01-04 01:55:50 +00:00
|
|
|
break;
|
|
|
|
case 'X': // Vendor extensions
|
2011-11-30 11:16:07 +00:00
|
|
|
if (strncmp("YSCSS=", tokstart, 6) == 0) {
|
2005-01-04 01:55:50 +00:00
|
|
|
// Older nonstandard pixel format representation
|
2011-11-30 11:16:07 +00:00
|
|
|
tokstart += 6;
|
|
|
|
if (strncmp("420JPEG", tokstart, 7) == 0)
|
2012-10-06 10:10:34 +00:00
|
|
|
alt_pix_fmt = AV_PIX_FMT_YUV420P;
|
2011-11-30 11:16:07 +00:00
|
|
|
else if (strncmp("420MPEG2", tokstart, 8) == 0)
|
2012-10-06 10:10:34 +00:00
|
|
|
alt_pix_fmt = AV_PIX_FMT_YUV420P;
|
2011-11-30 11:16:07 +00:00
|
|
|
else if (strncmp("420PALDV", tokstart, 8) == 0)
|
2012-10-06 10:10:34 +00:00
|
|
|
alt_pix_fmt = AV_PIX_FMT_YUV420P;
|
2011-11-30 11:16:07 +00:00
|
|
|
else if (strncmp("411", tokstart, 3) == 0)
|
2012-10-06 10:10:34 +00:00
|
|
|
alt_pix_fmt = AV_PIX_FMT_YUV411P;
|
2011-11-30 11:16:07 +00:00
|
|
|
else if (strncmp("422", tokstart, 3) == 0)
|
2012-10-06 10:10:34 +00:00
|
|
|
alt_pix_fmt = AV_PIX_FMT_YUV422P;
|
2011-11-30 11:16:07 +00:00
|
|
|
else if (strncmp("444", tokstart, 3) == 0)
|
2012-10-06 10:10:34 +00:00
|
|
|
alt_pix_fmt = AV_PIX_FMT_YUV444P;
|
2005-01-04 01:55:50 +00:00
|
|
|
}
|
2011-11-30 11:16:07 +00:00
|
|
|
while (tokstart < header_end && *tokstart != 0x20)
|
|
|
|
tokstart++;
|
2005-01-04 01:55:50 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-12-17 18:14:38 +00:00
|
|
|
}
|
2005-01-04 01:55:50 +00:00
|
|
|
|
2011-11-30 11:16:07 +00:00
|
|
|
if (width == -1 || height == -1) {
|
2005-01-04 01:55:50 +00:00
|
|
|
av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n");
|
2005-12-17 18:14:38 +00:00
|
|
|
return -1;
|
2005-01-04 01:55:50 +00:00
|
|
|
}
|
2005-12-17 18:14:38 +00:00
|
|
|
|
2012-10-06 10:10:34 +00:00
|
|
|
if (pix_fmt == AV_PIX_FMT_NONE) {
|
|
|
|
if (alt_pix_fmt == AV_PIX_FMT_NONE)
|
|
|
|
pix_fmt = AV_PIX_FMT_YUV420P;
|
2005-01-04 01:55:50 +00:00
|
|
|
else
|
|
|
|
pix_fmt = alt_pix_fmt;
|
|
|
|
}
|
|
|
|
|
2011-01-02 05:01:46 +00:00
|
|
|
if (raten <= 0 || rated <= 0) {
|
2005-01-04 01:55:50 +00:00
|
|
|
// Frame rate unknown
|
|
|
|
raten = 25;
|
|
|
|
rated = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aspectn == 0 && aspectd == 0) {
|
|
|
|
// Pixel aspect unknown
|
|
|
|
aspectd = 1;
|
|
|
|
}
|
2005-12-17 18:14:38 +00:00
|
|
|
|
2011-06-18 09:43:24 +00:00
|
|
|
st = avformat_new_stream(s, NULL);
|
2011-11-30 11:16:07 +00:00
|
|
|
if (!st)
|
2008-05-29 15:40:16 +00:00
|
|
|
return AVERROR(ENOMEM);
|
lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.
In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.
There are multiple important problems with this approach:
- the fields in AVCodecContext are in general one of
* stream parameters
* codec options
* codec state
However, it's not clear which ones are which. It is consequently
unclear which fields are a demuxer allowed to set or a muxer allowed to
read. This leads to erratic behaviour depending on whether decoding or
encoding is being performed or not (and whether it uses the AVStream
embedded codec context).
- various synchronization issues arising from the fact that the same
context is used by several different APIs (muxers/demuxers,
parsers, bitstream filters and encoders/decoders) simultaneously, with
there being no clear rules for who can modify what and the different
processes being typically delayed with respect to each other.
- avformat_find_stream_info() making it necessary to support opening
and closing a single codec context multiple times, thus
complicating the semantics of freeing various allocated objects in the
codec context.
Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2014-06-18 18:42:52 +00:00
|
|
|
st->codecpar->width = width;
|
|
|
|
st->codecpar->height = height;
|
2011-11-30 11:16:07 +00:00
|
|
|
av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1);
|
2011-11-29 18:28:15 +00:00
|
|
|
avpriv_set_pts_info(st, 64, rated, raten);
|
lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.
In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.
There are multiple important problems with this approach:
- the fields in AVCodecContext are in general one of
* stream parameters
* codec options
* codec state
However, it's not clear which ones are which. It is consequently
unclear which fields are a demuxer allowed to set or a muxer allowed to
read. This leads to erratic behaviour depending on whether decoding or
encoding is being performed or not (and whether it uses the AVStream
embedded codec context).
- various synchronization issues arising from the fact that the same
context is used by several different APIs (muxers/demuxers,
parsers, bitstream filters and encoders/decoders) simultaneously, with
there being no clear rules for who can modify what and the different
processes being typically delayed with respect to each other.
- avformat_find_stream_info() making it necessary to support opening
and closing a single codec context multiple times, thus
complicating the semantics of freeing various allocated objects in the
codec context.
Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2014-06-18 18:42:52 +00:00
|
|
|
st->avg_frame_rate = av_inv_q(st->time_base);
|
|
|
|
st->codecpar->format = pix_fmt;
|
|
|
|
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
|
|
|
st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
|
|
|
|
st->sample_aspect_ratio = (AVRational){ aspectn, aspectd };
|
|
|
|
st->codecpar->chroma_location = chroma_sample_location;
|
|
|
|
st->codecpar->field_order = field_order;
|
2003-08-05 09:32:31 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char header[MAX_FRAME_HEADER+1];
|
2012-10-05 13:53:32 +00:00
|
|
|
int packet_size, width, height, ret;
|
2003-08-05 09:32:31 +00:00
|
|
|
AVStream *st = s->streams[0];
|
|
|
|
|
2011-11-30 11:16:07 +00:00
|
|
|
for (i = 0; i < MAX_FRAME_HEADER; i++) {
|
2011-02-21 15:43:01 +00:00
|
|
|
header[i] = avio_r8(s->pb);
|
2005-12-22 01:10:11 +00:00
|
|
|
if (header[i] == '\n') {
|
2011-11-30 11:16:07 +00:00
|
|
|
header[i + 1] = 0;
|
2005-12-22 01:10:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-08-05 09:32:31 +00:00
|
|
|
}
|
2012-10-05 13:53:32 +00:00
|
|
|
if (s->pb->error)
|
|
|
|
return s->pb->error;
|
|
|
|
else if (s->pb->eof_reached)
|
|
|
|
return AVERROR_EOF;
|
|
|
|
else if (i == MAX_FRAME_HEADER)
|
|
|
|
return AVERROR_INVALIDDATA;
|
|
|
|
|
2011-11-30 11:16:07 +00:00
|
|
|
if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))
|
2012-10-05 13:53:32 +00:00
|
|
|
return AVERROR_INVALIDDATA;
|
2005-12-17 18:14:38 +00:00
|
|
|
|
lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.
In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.
There are multiple important problems with this approach:
- the fields in AVCodecContext are in general one of
* stream parameters
* codec options
* codec state
However, it's not clear which ones are which. It is consequently
unclear which fields are a demuxer allowed to set or a muxer allowed to
read. This leads to erratic behaviour depending on whether decoding or
encoding is being performed or not (and whether it uses the AVStream
embedded codec context).
- various synchronization issues arising from the fact that the same
context is used by several different APIs (muxers/demuxers,
parsers, bitstream filters and encoders/decoders) simultaneously, with
there being no clear rules for who can modify what and the different
processes being typically delayed with respect to each other.
- avformat_find_stream_info() making it necessary to support opening
and closing a single codec context multiple times, thus
complicating the semantics of freeing various allocated objects in the
codec context.
Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2014-06-18 18:42:52 +00:00
|
|
|
width = st->codecpar->width;
|
|
|
|
height = st->codecpar->height;
|
2003-08-05 09:32:31 +00:00
|
|
|
|
lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.
In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.
There are multiple important problems with this approach:
- the fields in AVCodecContext are in general one of
* stream parameters
* codec options
* codec state
However, it's not clear which ones are which. It is consequently
unclear which fields are a demuxer allowed to set or a muxer allowed to
read. This leads to erratic behaviour depending on whether decoding or
encoding is being performed or not (and whether it uses the AVStream
embedded codec context).
- various synchronization issues arising from the fact that the same
context is used by several different APIs (muxers/demuxers,
parsers, bitstream filters and encoders/decoders) simultaneously, with
there being no clear rules for who can modify what and the different
processes being typically delayed with respect to each other.
- avformat_find_stream_info() making it necessary to support opening
and closing a single codec context multiple times, thus
complicating the semantics of freeing various allocated objects in the
codec context.
Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2014-06-18 18:42:52 +00:00
|
|
|
packet_size = av_image_get_buffer_size(st->codecpar->format,
|
2015-10-14 09:33:24 +00:00
|
|
|
width, height, 1);
|
2003-08-05 09:32:31 +00:00
|
|
|
if (packet_size < 0)
|
2012-10-05 13:53:32 +00:00
|
|
|
return packet_size;
|
2003-08-05 09:32:31 +00:00
|
|
|
|
2012-10-05 13:53:32 +00:00
|
|
|
ret = av_get_packet(s->pb, pkt, packet_size);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
else if (ret != packet_size)
|
|
|
|
return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
|
2003-08-05 09:32:31 +00:00
|
|
|
|
|
|
|
pkt->stream_index = 0;
|
2005-05-26 20:17:12 +00:00
|
|
|
return 0;
|
2003-08-05 09:32:31 +00:00
|
|
|
}
|
|
|
|
|
2005-04-26 09:06:39 +00:00
|
|
|
static int yuv4_probe(AVProbeData *pd)
|
|
|
|
{
|
|
|
|
/* check file header */
|
2011-11-30 11:16:07 +00:00
|
|
|
if (strncmp(pd->buf, Y4M_MAGIC, sizeof(Y4M_MAGIC) - 1) == 0)
|
2005-04-26 09:06:39 +00:00
|
|
|
return AVPROBE_SCORE_MAX;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-25 22:03:28 +00:00
|
|
|
AVInputFormat ff_yuv4mpegpipe_demuxer = {
|
2011-07-16 20:18:12 +00:00
|
|
|
.name = "yuv4mpegpipe",
|
2012-07-24 21:51:41 +00:00
|
|
|
.long_name = NULL_IF_CONFIG_SMALL("YUV4MPEG pipe"),
|
2011-07-16 20:18:12 +00:00
|
|
|
.read_probe = yuv4_probe,
|
|
|
|
.read_header = yuv4_read_header,
|
|
|
|
.read_packet = yuv4_read_packet,
|
2012-04-06 14:50:48 +00:00
|
|
|
.extensions = "y4m",
|
2003-08-05 09:32:31 +00:00
|
|
|
};
|