--- libavformat/rawdec.c | 25 ++++++++++++++++++++++--- libavformat/rawdec.h | 6 ++++++ libavformat/rawvideodec.c | 3 ++- 3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index b545dbd..329985d 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -66,17 +66,23 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) av_set_pts_info(st, 64, 1, st->codec->sample_rate); break; } - case AVMEDIA_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: { + RawVideoDemuxerContext *s1 = s->priv_data; if(ap->time_base.num) av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); else av_set_pts_info(st, 64, 1, 25); - st->codec->width = ap->width; - st->codec->height = ap->height; + if (ap->width > 0) + s1->width = ap->width; + if (ap->height > 0) + s1->height = ap->height; + st->codec->width = s1->width; + st->codec->height = s1->height; st->codec->pix_fmt = ap->pix_fmt; if(st->codec->pix_fmt == PIX_FMT_NONE) st->codec->pix_fmt= PIX_FMT_YUV420P; break; + } default: return -1; } @@ -165,6 +171,19 @@ const AVClass ff_rawaudio_demuxer_class = { .version = LIBAVUTIL_VERSION_INT, }; +static const AVOption video_options[] = { + { "width", "", offsetof(RawVideoDemuxerContext, width), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "height", "", offsetof(RawVideoDemuxerContext, height), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { NULL }, +}; + +const AVClass ff_rawvideo_demuxer_class = { + .class_name = "Raw video demuxer", + .item_name = av_default_item_name, + .option = video_options, + .version = LIBAVUTIL_VERSION_INT, +}; + #if CONFIG_G722_DEMUXER AVInputFormat ff_g722_demuxer = { "g722", diff --git a/libavformat/rawdec.h b/libavformat/rawdec.h index e473eb2..bb5af47 100644 --- a/libavformat/rawdec.h +++ b/libavformat/rawdec.h @@ -31,7 +31,13 @@ typedef struct RawAudioDemuxerContext { int channels; } RawAudioDemuxerContext; +typedef struct RawVideoDemuxerContext { + AVClass *class; + int width, height; +} RawVideoDemuxerContext; + extern const AVClass ff_rawaudio_demuxer_class; +extern const AVClass ff_rawvideo_demuxer_class; int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap); diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c index a29f7da..cbe5714 100644 --- a/libavformat/rawvideodec.c +++ b/libavformat/rawvideodec.c @@ -47,11 +47,12 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt) AVInputFormat ff_rawvideo_demuxer = { "rawvideo", NULL_IF_CONFIG_SMALL("raw video format"), - 0, + sizeof(RawVideoDemuxerContext), NULL, ff_raw_read_header, rawvideo_read_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "yuv,cif,qcif,rgb", .value = CODEC_ID_RAWVIDEO, + .priv_class = &ff_rawvideo_demuxer_class, }; -- 1.7.5.1 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel