diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-05-26 03:00:37 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-05-26 03:28:22 +0200 |
commit | 39e4206dc672a596c742809c1466f8643a787208 (patch) | |
tree | 36b642fc5221090e5bd8d7bc1968a966a5c6c104 /libavformat | |
parent | 189db9c9829b970b3e28006c9f00d6960f71cff1 (diff) | |
parent | a2ee2843c09a6116b090020eff8213b86ea98bdb (diff) | |
download | ffmpeg-39e4206dc672a596c742809c1466f8643a787208.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (32 commits)
doc: create separate section for audio encoders
swscale: Remove orphaned, commented-out function declaration.
swscale: Eliminate rgb24toyv12_c() duplication.
Remove h263_msmpeg4 from MpegEncContext.
APIchanges: Fill in git hash for fps_probe_size (30315a8)
avformat: Add fpsprobesize as an AVOption.
avoptions: Return explicitly NAN or {0,0} if the option isn't found
rtmp: Reindent
rtmp: Don't try to do av_malloc(0)
tty: replace AVFormatParameters.sample_rate abuse with a private option.
Fix end time of last chapter in compute_chapters_end
ffmpeg: get rid of useless AVInputStream.nb_streams.
ffmpeg: simplify managing input files and streams
ffmpeg: purge redundant AVInputStream.index.
lavf: deprecate AVFormatParameters.channel.
libdc1394: add a private option for channel.
dv1394: add a private option for channel.
v4l2: reindent.
v4l2: add a private option for channel.
lavf: deprecate AVFormatParameters.standard.
...
Conflicts:
doc/APIchanges
doc/encoders.texi
ffmpeg.c
libavdevice/alsa-audio.h
libavformat/version.h
libavutil/opt.c
libswscale/rgb2rgb.h
libswscale/rgb2rgb_template.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/avformat.h | 24 | ||||
-rw-r--r-- | libavformat/mpegts.c | 22 | ||||
-rw-r--r-- | libavformat/options.c | 1 | ||||
-rw-r--r-- | libavformat/pcmdec.c | 3 | ||||
-rw-r--r-- | libavformat/rawdec.c | 38 | ||||
-rw-r--r-- | libavformat/rawdec.h | 9 | ||||
-rw-r--r-- | libavformat/rtmppkt.c | 8 | ||||
-rw-r--r-- | libavformat/rtmpproto.c | 2 | ||||
-rw-r--r-- | libavformat/tty.c | 24 | ||||
-rw-r--r-- | libavformat/utils.c | 2 | ||||
-rw-r--r-- | libavformat/version.h | 3 |
11 files changed, 114 insertions, 22 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index fc74444e92..1607a3092b 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -228,17 +228,20 @@ typedef struct AVProbeData { typedef struct AVFormatParameters { AVRational time_base; - int sample_rate; - int channels; +#if FF_API_FORMAT_PARAMETERS + attribute_deprecated int sample_rate; + attribute_deprecated int channels; +#endif int width; int height; enum PixelFormat pix_fmt; - int channel; /**< Used to select DV channel. */ - const char *standard; /**< TV standard, NTSC, PAL, SECAM */ - unsigned int mpeg2ts_raw:1; /**< Force raw MPEG-2 transport stream output, if possible. */ - unsigned int mpeg2ts_compute_pcr:1; /**< Compute exact PCR for each transport - stream packet (only meaningful if - mpeg2ts_raw is TRUE). */ +#if FF_API_FORMAT_PARAMETERS + attribute_deprecated int channel; /**< Used to select DV channel. */ + attribute_deprecated const char *standard; /**< deprecated, use demuxer-specific options instead. */ + attribute_deprecated unsigned int mpeg2ts_raw:1; /**< deprecated, use mpegtsraw demuxer */ + /**< deprecated, use mpegtsraw demuxer-specific options instead */ + attribute_deprecated unsigned int mpeg2ts_compute_pcr:1; +#endif unsigned int initial_pause:1; /**< Do not begin to play the stream immediately (RTSP only). */ unsigned int prealloced_context:1; @@ -824,6 +827,11 @@ typedef struct AVFormatContext { * - decoding: Unused. */ int64_t start_time_realtime; + + /** + * decoding: number of frames used to probe fps + */ + int fps_probe_size; } AVFormatContext; typedef struct AVPacketList { diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index f59b7c2ed2..ea11a3eaf8 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -25,6 +25,8 @@ #include "libavutil/crc.h" #include "libavutil/intreadwrite.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" #include "libavcodec/bytestream.h" #include "avformat.h" #include "mpegts.h" @@ -86,6 +88,7 @@ struct Program { }; struct MpegTSContext { + const AVClass *class; /* user data */ AVFormatContext *stream; /** raw packet size, including FEC if present */ @@ -122,6 +125,19 @@ struct MpegTSContext { MpegTSFilter *pids[NB_PID_MAX]; }; +static const AVOption options[] = { + {"compute_pcr", "Compute exact PCR for each transport stream packet.", offsetof(MpegTSContext, mpeg2ts_compute_pcr), FF_OPT_TYPE_INT, + {.dbl = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, + { NULL }, +}; + +static const AVClass mpegtsraw_class = { + .class_name = "mpegtsraw demuxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + /* TS stream handling */ enum MpegTSState { @@ -1455,13 +1471,16 @@ static int mpegts_read_header(AVFormatContext *s, int len; int64_t pos; +#if FF_API_FORMAT_PARAMETERS if (ap) { - ts->mpeg2ts_compute_pcr = ap->mpeg2ts_compute_pcr; + if (ap->mpeg2ts_compute_pcr) + ts->mpeg2ts_compute_pcr = ap->mpeg2ts_compute_pcr; if(ap->mpeg2ts_raw){ av_log(s, AV_LOG_ERROR, "use mpegtsraw_demuxer!\n"); return -1; } } +#endif /* read the first 1024 bytes to get packet size */ pos = avio_tell(pb); @@ -1883,4 +1902,5 @@ AVInputFormat ff_mpegtsraw_demuxer = { #ifdef USE_SYNCPOINT_SEARCH .read_seek2 = read_seek2, #endif + .priv_class = &mpegtsraw_class, }; diff --git a/libavformat/options.c b/libavformat/options.c index 5e0e3a428d..6281b7fbcd 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -60,6 +60,7 @@ static const AVOption options[]={ {"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"}, {"ts", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"}, {"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E|D}, +{"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), FF_OPT_TYPE_INT, -1, -1, INT_MAX-1, D}, {NULL}, }; diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c index 6441d89c5c..ab3b739ccb 100644 --- a/libavformat/pcmdec.c +++ b/libavformat/pcmdec.c @@ -50,7 +50,7 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) AVInputFormat ff_pcm_ ## name ## _demuxer = {\ #name,\ NULL_IF_CONFIG_SMALL(long_name),\ - 0,\ + sizeof(RawAudioDemuxerContext),\ NULL,\ ff_raw_read_header,\ raw_read_packet,\ @@ -59,6 +59,7 @@ AVInputFormat ff_pcm_ ## name ## _demuxer = {\ .flags= AVFMT_GENERIC_INDEX,\ .extensions = ext,\ .value = codec,\ + .priv_class = &ff_rawaudio_demuxer_class,\ }; PCMDEF(f64be, "PCM 64 bit floating-point big-endian format", diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index 0387e3d266..daacae0c24 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -23,6 +23,7 @@ #include "avformat.h" #include "avio_internal.h" #include "rawdec.h" +#include "libavutil/opt.h" /* raw input */ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) @@ -43,15 +44,28 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->codec_id = id; switch(st->codec->codec_type) { - case AVMEDIA_TYPE_AUDIO: - st->codec->sample_rate = ap->sample_rate; - if(ap->channels) st->codec->channels = ap->channels; - else st->codec->channels = 1; + case AVMEDIA_TYPE_AUDIO: { + RawAudioDemuxerContext *s1 = s->priv_data; + +#if FF_API_FORMAT_PARAMETERS + if (ap->sample_rate) + st->codec->sample_rate = ap->sample_rate; + if (ap->channels) + st->codec->channels = ap->channels; + else st->codec->channels = 1; +#endif + + if (s1->sample_rate) + st->codec->sample_rate = s1->sample_rate; + if (s1->channels) + st->codec->channels = s1->channels; + st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id); assert(st->codec->bits_per_coded_sample > 0); st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8; av_set_pts_info(st, 64, 1, st->codec->sample_rate); break; + } case AVMEDIA_TYPE_VIDEO: if(ap->time_base.num) av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); @@ -139,17 +153,31 @@ int ff_raw_video_read_header(AVFormatContext *s, /* Note: Do not forget to add new entries to the Makefile as well. */ +static const AVOption audio_options[] = { + { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "channels", "", offsetof(RawAudioDemuxerContext, channels), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { NULL }, +}; + +const AVClass ff_rawaudio_demuxer_class = { + .class_name = "rawaudio demuxer", + .item_name = av_default_item_name, + .option = audio_options, + .version = LIBAVUTIL_VERSION_INT, +}; + #if CONFIG_G722_DEMUXER AVInputFormat ff_g722_demuxer = { "g722", NULL_IF_CONFIG_SMALL("raw G.722"), - 0, + sizeof(RawAudioDemuxerContext), NULL, ff_raw_read_header, ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "g722,722", .value = CODEC_ID_ADPCM_G722, + .priv_class = &ff_rawaudio_demuxer_class, }; #endif diff --git a/libavformat/rawdec.h b/libavformat/rawdec.h index 0b0cf1beef..a989ea9ce6 100644 --- a/libavformat/rawdec.h +++ b/libavformat/rawdec.h @@ -23,6 +23,15 @@ #define AVFORMAT_RAWDEC_H #include "avformat.h" +#include "libavutil/log.h" + +typedef struct RawAudioDemuxerContext { + AVClass *class; + int sample_rate; + int channels; +} RawAudioDemuxerContext; + +extern const AVClass ff_rawaudio_demuxer_class; int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap); diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index 53c6a5fe19..4b6d549f74 100644 --- a/libavformat/rtmppkt.c +++ b/libavformat/rtmppkt.c @@ -233,9 +233,11 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt, int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type, int timestamp, int size) { - pkt->data = av_malloc(size); - if (!pkt->data) - return AVERROR(ENOMEM); + if (size) { + pkt->data = av_malloc(size); + if (!pkt->data) + return AVERROR(ENOMEM); + } pkt->data_size = size; pkt->channel_id = channel_id; pkt->type = type; diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index b10cfb6ca7..b8714c9ffa 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -683,7 +683,7 @@ static int get_packet(URLContext *s, int for_header) return AVERROR_EOF; for (;;) { - RTMPPacket rpkt; + RTMPPacket rpkt = { 0 }; if ((ret = ff_rtmp_packet_read(rt->stream, &rpkt, rt->chunk_size, rt->prev_pkt[0])) <= 0) { if (ret == 0) { diff --git a/libavformat/tty.c b/libavformat/tty.c index b288d15393..171099d3cb 100644 --- a/libavformat/tty.c +++ b/libavformat/tty.c @@ -26,12 +26,13 @@ #include "libavutil/intreadwrite.h" #include "libavutil/avstring.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" #include "avformat.h" #include "sauce.h" -#define LINE_RATE 6000 /* characters per second */ - typedef struct { + AVClass *class; int chars_per_frame; uint64_t fsize; /**< file size less metadata buffer */ } TtyDemuxContext; @@ -86,7 +87,11 @@ static int read_header(AVFormatContext *avctx, } /* simulate tty display speed */ - s->chars_per_frame = FFMAX(av_q2d(st->time_base) * (ap->sample_rate ? ap->sample_rate : LINE_RATE), 1); +#if FF_API_FORMAT_PARAMETERS + if (ap->sample_rate) + s->chars_per_frame = ap->sample_rate; +#endif + s->chars_per_frame = FFMAX(av_q2d(st->time_base)*s->chars_per_frame, 1); if (avctx->pb->seekable) { s->fsize = avio_size(avctx->pb); @@ -124,6 +129,18 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt) return 0; } +static const AVOption options[] = { + { "chars_per_frame", "", offsetof(TtyDemuxContext, chars_per_frame), FF_OPT_TYPE_INT, {.dbl = 6000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM}, + { NULL }, +}; + +static const AVClass tty_demuxer_class = { + .class_name = "TTY demuxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVInputFormat ff_tty_demuxer = { .name = "tty", .long_name = NULL_IF_CONFIG_SMALL("Tele-typewriter"), @@ -131,4 +148,5 @@ AVInputFormat ff_tty_demuxer = { .read_header = read_header, .read_packet = read_packet, .extensions = "ans,art,asc,diz,ice,nfo,txt,vt", + .priv_class = &tty_demuxer_class, }; diff --git a/libavformat/utils.c b/libavformat/utils.c index 20b21f29db..3c9a89dc64 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2272,6 +2272,8 @@ int av_find_stream_info(AVFormatContext *ic) the correct fps */ if (av_q2d(st->time_base) > 0.0005) fps_analyze_framecount *= 2; + if (ic->fps_probe_size >= 0) + fps_analyze_framecount = ic->fps_probe_size; /* variable fps and no guess at the real fps */ if( tb_unreliable(st->codec) && !(st->r_frame_rate.num && st->avg_frame_rate.num) && st->info->duration_count < fps_analyze_framecount diff --git a/libavformat/version.h b/libavformat/version.h index 76b86ed323..fe8e85dadf 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -71,5 +71,8 @@ #ifndef FF_API_ALLOC_OUTPUT_CONTEXT #define FF_API_ALLOC_OUTPUT_CONTEXT (LIBAVFORMAT_VERSION_MAJOR < 54) #endif +#ifndef FF_API_FORMAT_PARAMETERS +#define FF_API_FORMAT_PARAMETERS (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif #endif /* AVFORMAT_VERSION_H */ |