diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-26 14:07:04 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-26 14:24:57 +0200 |
commit | 507f2940ccdcedf2fdc064c5fb6022b60bace8ca (patch) | |
tree | a367ef88e7671ef3155d52bf0f8137fc1c2b0339 | |
parent | 9f36ec6aa936515a703f6d7ff32826aa28684f1e (diff) | |
parent | 1b891d17c531e8a63c2974aab4bf997ce70746f3 (diff) | |
download | ffmpeg-507f2940ccdcedf2fdc064c5fb6022b60bace8ca.tar.gz |
Merge commit '1b891d17c531e8a63c2974aab4bf997ce70746f3'
* commit '1b891d17c531e8a63c2974aab4bf997ce70746f3':
avconv: fix bitrate report when writing to /dev/null
avfilter: fix graphparser memleaks on error paths
rawdec: remove ff_raw_read_header
pcmdec: remove dependency from rawdec
g722: refactor out of rawdec.c
rawvideo: use a specific read_header
Conflicts:
ffmpeg.c
libavformat/Makefile
libavformat/rawdec.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | ffmpeg.c | 10 | ||||
-rw-r--r-- | libavfilter/graphparser.c | 24 | ||||
-rw-r--r-- | libavformat/Makefile | 44 | ||||
-rw-r--r-- | libavformat/g722.c | 57 | ||||
-rw-r--r-- | libavformat/pcmdec.c | 41 | ||||
-rw-r--r-- | libavformat/rawdec.c | 88 | ||||
-rw-r--r-- | libavformat/rawdec.h | 8 | ||||
-rw-r--r-- | libavformat/rawvideodec.c | 68 |
8 files changed, 199 insertions, 141 deletions
@@ -1082,10 +1082,14 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti oc = output_files[0]->ctx; total_size = avio_size(oc->pb); - if (total_size < 0) { // FIXME improve avio_size() so it works with non seekable output too + if (total_size <= 0) // FIXME improve avio_size() so it works with non seekable output too total_size = avio_tell(oc->pb); - if (total_size < 0) - total_size = 0; + if (total_size < 0) { + char errbuf[128]; + av_strerror(total_size, errbuf, sizeof(errbuf)); + av_log(NULL, AV_LOG_VERBOSE, "Bitrate not available, " + "avio_tell() failed: %s\n", errbuf); + total_size = 0; } buf[0] = '\0'; diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index aed7624ccc..0ce823a10d 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -239,10 +239,11 @@ static int link_filter_inouts(AVFilterContext *filt_ctx, return AVERROR(ENOMEM); if (p->filter_ctx) { - if ((ret = link_filter(p->filter_ctx, p->pad_idx, filt_ctx, pad, log_ctx)) < 0) - return ret; + ret = link_filter(p->filter_ctx, p->pad_idx, filt_ctx, pad, log_ctx); av_free(p->name); av_free(p); + if (ret < 0) + return ret; } else { p->filter_ctx = filt_ctx; p->pad_idx = pad; @@ -290,8 +291,10 @@ static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs, av_free(name); } else { /* Not in the list, so add it as an input */ - if (!(match = av_mallocz(sizeof(AVFilterInOut)))) + if (!(match = av_mallocz(sizeof(AVFilterInOut)))) { + av_free(name); return AVERROR(ENOMEM); + } match->name = name; match->pad_idx = pad; } @@ -319,24 +322,27 @@ static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs, AVFilterInOut *match; AVFilterInOut *input = *curr_inputs; + + if (!name) + return AVERROR(EINVAL); + if (!input) { av_log(log_ctx, AV_LOG_ERROR, - "No output pad can be associated to link label '%s'.\n", - name); + "No output pad can be associated to link label '%s'.\n", name); + av_free(name); return AVERROR(EINVAL); } *curr_inputs = (*curr_inputs)->next; - if (!name) - return AVERROR(EINVAL); - /* First check if the label is not in the open_inputs list */ match = extract_inout(name, open_inputs); if (match) { if ((ret = link_filter(input->filter_ctx, input->pad_idx, - match->filter_ctx, match->pad_idx, log_ctx)) < 0) + match->filter_ctx, match->pad_idx, log_ctx)) < 0) { + av_free(name); return ret; + } av_free(match->name); av_free(name); av_free(match); diff --git a/libavformat/Makefile b/libavformat/Makefile index dc8e271de4..ff16b3b9c4 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -112,7 +112,7 @@ OBJS-$(CONFIG_GIF_MUXER) += gif.o OBJS-$(CONFIG_GSM_DEMUXER) += gsmdec.o OBJS-$(CONFIG_GXF_DEMUXER) += gxf.o OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o audiointerleave.o -OBJS-$(CONFIG_G722_DEMUXER) += rawdec.o +OBJS-$(CONFIG_G722_DEMUXER) += g722.o rawdec.o OBJS-$(CONFIG_G722_MUXER) += rawenc.o OBJS-$(CONFIG_G723_1_DEMUXER) += g723_1.o OBJS-$(CONFIG_G723_1_MUXER) += rawenc.o @@ -220,51 +220,51 @@ OBJS-$(CONFIG_OGG_MUXER) += oggenc.o \ OBJS-$(CONFIG_OMA_DEMUXER) += omadec.o pcm.o oma.o OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o oma.o id3v2enc.o OBJS-$(CONFIG_PAF_DEMUXER) += paf.o -OBJS-$(CONFIG_PCM_ALAW_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_ALAW_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_ALAW_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_F32BE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_F32BE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_F32BE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_F32LE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_F32LE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_F32LE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_F64BE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_F64BE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_F64BE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_F64LE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_F64LE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_F64LE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_MULAW_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_MULAW_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_MULAW_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_S16BE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_S16BE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_S16BE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_S16LE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_S16LE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_S16LE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_S24BE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_S24BE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_S24BE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_S24LE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_S24LE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_S24LE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_S32BE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_S32BE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_S32BE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_S32LE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_S32LE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_S32LE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_S8_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_S8_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_S8_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_U16BE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_U16BE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_U16BE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_U16LE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_U16LE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_U16LE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_U24BE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_U24BE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_U24BE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_U24LE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_U24LE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_U24LE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_U32BE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_U32BE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_U32BE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_U32LE_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_U32LE_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_U32LE_MUXER) += pcmenc.o rawenc.o -OBJS-$(CONFIG_PCM_U8_DEMUXER) += pcmdec.o pcm.o rawdec.o +OBJS-$(CONFIG_PCM_U8_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_U8_MUXER) += pcmenc.o rawenc.o OBJS-$(CONFIG_PMP_DEMUXER) += pmpdec.o OBJS-$(CONFIG_PVA_DEMUXER) += pva.o OBJS-$(CONFIG_QCP_DEMUXER) += qcp.o OBJS-$(CONFIG_R3D_DEMUXER) += r3d.o -OBJS-$(CONFIG_RAWVIDEO_DEMUXER) += rawvideodec.o rawdec.o +OBJS-$(CONFIG_RAWVIDEO_DEMUXER) += rawvideodec.o OBJS-$(CONFIG_RAWVIDEO_MUXER) += rawenc.o OBJS-$(CONFIG_REALTEXT_DEMUXER) += realtextdec.o OBJS-$(CONFIG_RL2_DEMUXER) += rl2.o diff --git a/libavformat/g722.c b/libavformat/g722.c new file mode 100644 index 0000000000..1a87c7d28c --- /dev/null +++ b/libavformat/g722.c @@ -0,0 +1,57 @@ +/* + * g722 raw demuxer + * Copyright (c) 2010 Martin Storsjo + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * 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 + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/avassert.h" +#include "avformat.h" +#include "internal.h" +#include "rawdec.h" + +static int g722_read_header(AVFormatContext *s) +{ + AVStream *st; + + st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; + st->codec->codec_id = AV_CODEC_ID_ADPCM_G722; + st->codec->sample_rate = 16000; + st->codec->channels = 1; + + st->codec->bits_per_coded_sample = + av_get_bits_per_sample(st->codec->codec_id); + + av_assert0(st->codec->bits_per_coded_sample > 0); + + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); + return 0; +} + +AVInputFormat ff_g722_demuxer = { + .name = "g722", + .long_name = NULL_IF_CONFIG_SMALL("raw G.722"), + .read_header = g722_read_header, + .read_packet = ff_raw_read_partial_packet, + .flags = AVFMT_GENERIC_INDEX, + .extensions = "g722,722", + .raw_codec_id = AV_CODEC_ID_ADPCM_G722, +}; diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c index 178c251f14..5ed572b8f7 100644 --- a/libavformat/pcmdec.c +++ b/libavformat/pcmdec.c @@ -20,7 +20,7 @@ */ #include "avformat.h" -#include "rawdec.h" +#include "internal.h" #include "pcm.h" #include "libavutil/log.h" #include "libavutil/opt.h" @@ -28,6 +28,39 @@ #define RAW_SAMPLES 1024 +typedef struct RawAudioDemuxerContext { + AVClass *class; + int sample_rate; + int channels; +} RawAudioDemuxerContext; + +static int raw_read_header(AVFormatContext *s) +{ + RawAudioDemuxerContext *s1 = s->priv_data; + AVStream *st; + + st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + + + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; + st->codec->codec_id = s->iformat->raw_codec_id; + st->codec->sample_rate = s1->sample_rate; + st->codec->channels = s1->channels; + + st->codec->bits_per_coded_sample = + av_get_bits_per_sample(st->codec->codec_id); + + av_assert0(st->codec->bits_per_coded_sample > 0); + + st->codec->block_align = + st->codec->bits_per_coded_sample * st->codec->channels / 8; + + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); + return 0; +} + static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size, bps; @@ -51,8 +84,8 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) } static const AVOption pcm_options[] = { - { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, - { "channels", "", offsetof(RawAudioDemuxerContext, channels), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 44100}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "channels", "", offsetof(RawAudioDemuxerContext, channels), AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; @@ -67,7 +100,7 @@ AVInputFormat ff_pcm_ ## name_ ## _demuxer = { \ .name = #name_, \ .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ .priv_data_size = sizeof(RawAudioDemuxerContext), \ - .read_header = ff_raw_read_header, \ + .read_header = raw_read_header, \ .read_packet = raw_read_packet, \ .read_seek = ff_pcm_read_seek, \ .flags = AVFMT_GENERIC_INDEX, \ diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index 4020666ed8..07c2782c67 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -29,82 +29,6 @@ #include "libavutil/pixdesc.h" #include "libavutil/avassert.h" -/* raw input */ -int ff_raw_read_header(AVFormatContext *s) -{ - AVStream *st; - enum AVCodecID id; - - st = avformat_new_stream(s, NULL); - if (!st) - return AVERROR(ENOMEM); - - id = s->iformat->raw_codec_id; - if (id == AV_CODEC_ID_RAWVIDEO) { - st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - } else { - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - } - st->codec->codec_id = id; - - switch(st->codec->codec_type) { - case AVMEDIA_TYPE_AUDIO: { - RawAudioDemuxerContext *s1 = s->priv_data; - - st->codec->channels = 1; - - if (id == AV_CODEC_ID_ADPCM_G722) - st->codec->sample_rate = 16000; - - if (s1 && s1->sample_rate) - st->codec->sample_rate = s1->sample_rate; - if (st->codec->sample_rate <= 0) { - av_log(s, AV_LOG_WARNING, "Invalid sample rate %d specified using default of 44100\n", - st->codec->sample_rate); - st->codec->sample_rate= 44100; - } - - if (s1 && s1->channels) - st->codec->channels = s1->channels; - - st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id); - av_assert0(st->codec->bits_per_coded_sample > 0); - st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8; - avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); - break; - } - case AVMEDIA_TYPE_VIDEO: { - FFRawVideoDemuxerContext *s1 = s->priv_data; - int width = 0, height = 0, ret = 0; - enum AVPixelFormat pix_fmt; - AVRational framerate; - - if (s1->video_size && (ret = av_parse_video_size(&width, &height, s1->video_size)) < 0) { - av_log(s, AV_LOG_ERROR, "Couldn't parse video size.\n"); - goto fail; - } - if ((pix_fmt = av_get_pix_fmt(s1->pixel_format)) == AV_PIX_FMT_NONE) { - av_log(s, AV_LOG_ERROR, "No such pixel format: %s.\n", s1->pixel_format); - ret = AVERROR(EINVAL); - goto fail; - } - if ((ret = av_parse_video_rate(&framerate, s1->framerate)) < 0) { - av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s1->framerate); - goto fail; - } - avpriv_set_pts_info(st, 64, framerate.den, framerate.num); - st->codec->width = width; - st->codec->height = height; - st->codec->pix_fmt = pix_fmt; -fail: - return ret; - } - default: - return -1; - } - return 0; -} - #define RAW_PACKET_SIZE 1024 int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) @@ -181,18 +105,6 @@ const AVOption ff_rawvideo_options[] = { { NULL }, }; -#if CONFIG_G722_DEMUXER -AVInputFormat ff_g722_demuxer = { - .name = "g722", - .long_name = NULL_IF_CONFIG_SMALL("raw G.722"), - .read_header = ff_raw_read_header, - .read_packet = ff_raw_read_partial_packet, - .flags = AVFMT_GENERIC_INDEX, - .extensions = "g722,722", - .raw_codec_id = AV_CODEC_ID_ADPCM_G722, -}; -#endif - #if CONFIG_LATM_DEMUXER AVInputFormat ff_latm_demuxer = { .name = "latm", diff --git a/libavformat/rawdec.h b/libavformat/rawdec.h index 5812e5019b..d978295ce2 100644 --- a/libavformat/rawdec.h +++ b/libavformat/rawdec.h @@ -26,12 +26,6 @@ #include "libavutil/log.h" #include "libavutil/opt.h" -typedef struct RawAudioDemuxerContext { - AVClass *class; - int sample_rate; - int channels; -} RawAudioDemuxerContext; - typedef struct FFRawVideoDemuxerContext { const AVClass *class; /**< Class for private options. */ char *video_size; /**< String describing video size, set by a private option. */ @@ -41,8 +35,6 @@ typedef struct FFRawVideoDemuxerContext { extern const AVOption ff_rawvideo_options[]; -int ff_raw_read_header(AVFormatContext *s); - int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt); int ff_raw_audio_read_header(AVFormatContext *s); diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c index 2828c8d472..b2ca663d0b 100644 --- a/libavformat/rawvideodec.c +++ b/libavformat/rawvideodec.c @@ -19,8 +19,63 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/parseutils.h" +#include "libavutil/pixdesc.h" +#include "libavutil/opt.h" +#include "internal.h" #include "avformat.h" -#include "rawdec.h" + +typedef struct RawVideoDemuxerContext { + const AVClass *class; /**< Class for private options. */ + char *video_size; /**< String describing video size, set by a private option. */ + char *pixel_format; /**< Set by a private option. */ + char *framerate; /**< String describing framerate, set by a private option. */ +} RawVideoDemuxerContext; + + +static int rawvideo_read_header(AVFormatContext *ctx) +{ + RawVideoDemuxerContext *s = ctx->priv_data; + int width = 0, height = 0, ret = 0; + enum AVPixelFormat pix_fmt; + AVRational framerate; + AVStream *st; + + st = avformat_new_stream(ctx, NULL); + if (!st) + return AVERROR(ENOMEM); + + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; + + st->codec->codec_id = ctx->iformat->raw_codec_id; + + if (s->video_size && + (ret = av_parse_video_size(&width, &height, s->video_size)) < 0) { + av_log(ctx, AV_LOG_ERROR, "Couldn't parse video size.\n"); + return ret; + } + + if ((pix_fmt = av_get_pix_fmt(s->pixel_format)) == AV_PIX_FMT_NONE) { + av_log(ctx, AV_LOG_ERROR, "No such pixel format: %s.\n", + s->pixel_format); + return AVERROR(EINVAL); + } + + if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) { + av_log(ctx, AV_LOG_ERROR, "Could not parse framerate: %s.\n", + s->framerate); + return ret; + } + + avpriv_set_pts_info(st, 64, framerate.den, framerate.num); + + st->codec->width = width; + st->codec->height = height; + st->codec->pix_fmt = pix_fmt; + + return 0; +} + static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt) { @@ -34,9 +89,8 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt) if (packet_size < 0) return -1; - ret= av_get_packet(s->pb, pkt, packet_size); - pkt->pts= - pkt->dts= pkt->pos / packet_size; + ret = av_get_packet(s->pb, pkt, packet_size); + pkt->pts = pkt->dts = pkt->pos / packet_size; pkt->stream_index = 0; if (ret < 0) @@ -44,7 +98,7 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt) return 0; } -#define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x) +#define OFFSET(x) offsetof(RawVideoDemuxerContext, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption rawvideo_options[] = { { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, @@ -63,8 +117,8 @@ static const AVClass rawvideo_demuxer_class = { AVInputFormat ff_rawvideo_demuxer = { .name = "rawvideo", .long_name = NULL_IF_CONFIG_SMALL("raw video"), - .priv_data_size = sizeof(FFRawVideoDemuxerContext), - .read_header = ff_raw_read_header, + .priv_data_size = sizeof(RawVideoDemuxerContext), + .read_header = rawvideo_read_header, .read_packet = rawvideo_read_packet, .flags = AVFMT_GENERIC_INDEX, .extensions = "yuv,cif,qcif,rgb", |