From 91b412e786055aec3c5b6529a0c9ecc70fde8a6d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 28 Nov 2011 11:47:02 +0100 Subject: [PATCH 01/11] avconv: update InputStream.pts in the streamcopy case. This was broken in 2a651b719c309c5e2fc663a5a9d6ca36153ab98f. --- avconv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/avconv.c b/avconv.c index 4c5498ad93..067678d637 100644 --- a/avconv.c +++ b/avconv.c @@ -1906,6 +1906,7 @@ static int output_packet(InputStream *ist, /* handle stream copy */ if (!ist->decoding_needed) { rate_emu_sleep(ist); + ist->pts = ist->next_pts; switch (ist->st->codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) / From 2092232581468e3d656805e2b0effd14092dc6f5 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 28 Nov 2011 10:02:21 +0100 Subject: [PATCH 02/11] lavf: estimate frame duration from r_frame_rate. If r_frame_rate is set, it should be more reliable for this than either codec or stream timebase. --- libavformat/utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 2b378ab712..29eaf1b15a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -826,7 +826,10 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st, *pden = 0; switch(st->codec->codec_type) { case AVMEDIA_TYPE_VIDEO: - if(st->time_base.num*1000LL > st->time_base.den){ + if (st->r_frame_rate.num) { + *pnum = st->r_frame_rate.den; + *pden = st->r_frame_rate.num; + } else if(st->time_base.num*1000LL > st->time_base.den) { *pnum = st->time_base.num; *pden = st->time_base.den; }else if(st->codec->time_base.num*1000LL > st->codec->time_base.den){ From 741a05a2936505476ec0ff484d1251276635af73 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 28 Nov 2011 11:15:06 +0100 Subject: [PATCH 03/11] avconv: compute next_pts from input packet duration when possible. --- avconv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/avconv.c b/avconv.c index 067678d637..ab0d4eca20 100644 --- a/avconv.c +++ b/avconv.c @@ -1747,7 +1747,9 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int } ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts, decoded_frame->pkt_dts); - if (ist->st->codec->time_base.num != 0) { + if (pkt->duration) + ist->next_pts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); + else if (ist->st->codec->time_base.num != 0) { int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : ist->st->codec->ticks_per_frame; ist->next_pts += ((int64_t)AV_TIME_BASE * From d3e3ffa501beab09ac7c73d10235b372c0311615 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 28 Nov 2011 09:17:46 +0100 Subject: [PATCH 04/11] rmdec: don't set codec timebase. It's not supposed to be set outside of lavc. Set r_frame_rate instead. --- libavformat/rmdec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index e3b3e5ac32..a13f970fc6 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -332,10 +332,9 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb, if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (avio_tell(pb) - codec_pos))) < 0) return ret; - av_reduce(&st->codec->time_base.num, &st->codec->time_base.den, + av_reduce(&st->r_frame_rate.den, &st->r_frame_rate.num, 0x10000, fps, (1 << 30) - 1); - st->avg_frame_rate.num = st->codec->time_base.den; - st->avg_frame_rate.den = st->codec->time_base.num; + st->avg_frame_rate = st->r_frame_rate; } skip: From c98c1f434eed06390f4990dd23f7ec15dbe53703 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 28 Nov 2011 09:38:32 +0100 Subject: [PATCH 05/11] matroskadec: don't set codec timebase. It's not supposed to be set outside of lavc. --- libavformat/matroskadec.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index a40aa1c469..b136bbae1c 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1519,10 +1519,6 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) if (track->flag_forced) st->disposition |= AV_DISPOSITION_FORCED; - if (track->default_duration) - av_reduce(&st->codec->time_base.num, &st->codec->time_base.den, - track->default_duration, 1000000000, 30000); - if (!st->codec->extradata) { if(extradata){ st->codec->extradata = extradata; From 7bb3e6259492c9923881f906be88b0c2eb5e071e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 29 Nov 2011 11:10:31 +0100 Subject: [PATCH 06/11] avconv: make copy_tb on by default. I.e. on streamcopy set output codec timebase from input stream timebase (as opposed to input codec timebase). This should be more sane, because since the stream is not decoded, the input codec tb has no relation to the timestamps of the copied packets. --- avconv.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/avconv.c b/avconv.c index ab0d4eca20..d6045b7ef4 100644 --- a/avconv.c +++ b/avconv.c @@ -113,7 +113,7 @@ static int video_sync_method= -1; static int audio_sync_method= 0; static float audio_drift_threshold= 0.1; static int copy_ts= 0; -static int copy_tb; +static int copy_tb = 1; static int opt_shortest = 0; static char *vstats_filename; static FILE *vstats_file; @@ -2067,9 +2067,7 @@ static int transcode_init(OutputFile *output_files, } memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size = icodec->extradata_size; - if (!copy_tb && - av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && - av_q2d(ist->st->time_base) < 1.0/500) { + if (!copy_tb) { codec->time_base = icodec->time_base; codec->time_base.num *= icodec->ticks_per_frame; av_reduce(&codec->time_base.num, &codec->time_base.den, From 258366066479391aa998e3c8e87f70bec559db72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 29 Nov 2011 16:51:26 +0200 Subject: [PATCH 07/11] rtpdec: Add an init function that can do custom codec context initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/rtpdec.h | 1 + libavformat/rtsp.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/libavformat/rtpdec.h b/libavformat/rtpdec.h index eb1e62daec..9e2bfd01d5 100644 --- a/libavformat/rtpdec.h +++ b/libavformat/rtpdec.h @@ -122,6 +122,7 @@ struct RTPDynamicProtocolHandler_s { * require any custom depacketization code. */ // may be null + int (*init)(AVFormatContext *s, int st_index, PayloadContext *priv_data); ///< Initialize dynamic protocol handler, called after the full rtpmap line is parsed int (*parse_sdp_a_line) (AVFormatContext *s, int st_index, PayloadContext *priv_data, diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index d0e9bbf6af..1f32050c69 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -251,6 +251,9 @@ static int sdp_parse_rtpmap(AVFormatContext *s, default: break; } + if (rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->init) + rtsp_st->dynamic_handler->init(s, st->index, + rtsp_st->dynamic_protocol_context); return 0; } @@ -387,6 +390,9 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, handler = ff_rtp_handler_find_by_id( rtsp_st->sdp_payload_type, st->codec->codec_type); init_rtp_handler(handler, rtsp_st, st->codec); + if (handler && handler->init) + handler->init(s, st->index, + rtsp_st->dynamic_protocol_context); } } /* put a default control url */ From 06d7325ab1fcc009f0183be3a0b0504f6d99edfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Sluge=C5=88?= Date: Mon, 7 Nov 2011 12:13:55 +0100 Subject: [PATCH 08/11] rtpdec: Add support for G726 audio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This requires using a separate init function, since there isn't necessarily any fmtp lines for this codec, so parse_sdp_a_line won't be called. Incorporating it with the alloc function wouldn't do either, since it is called before the full rtpmap line is parsed (where the sample rate is extracted). Signed-off-by: Martin Storsjö --- libavformat/Makefile | 1 + libavformat/rtpdec.c | 5 ++ libavformat/rtpdec_formats.h | 4 ++ libavformat/rtpdec_g726.c | 102 +++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 libavformat/rtpdec_g726.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 64b2d823ed..f3f8679b42 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -247,6 +247,7 @@ OBJS-$(CONFIG_RTPDEC) += rdt.o \ rtpdec.o \ rtpdec_amr.o \ rtpdec_asf.o \ + rtpdec_g726.o \ rtpdec_h263.o \ rtpdec_h264.o \ rtpdec_latm.o \ diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 88cf15bdea..7e8b52adad 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -83,6 +83,11 @@ void av_register_rtp_dynamic_payload_handlers(void) ff_register_dynamic_payload_handler(&ff_qt_rtp_vid_handler); ff_register_dynamic_payload_handler(&ff_quicktime_rtp_aud_handler); ff_register_dynamic_payload_handler(&ff_quicktime_rtp_vid_handler); + + ff_register_dynamic_payload_handler(&ff_g726_16_dynamic_handler); + ff_register_dynamic_payload_handler(&ff_g726_24_dynamic_handler); + ff_register_dynamic_payload_handler(&ff_g726_32_dynamic_handler); + ff_register_dynamic_payload_handler(&ff_g726_40_dynamic_handler); } RTPDynamicProtocolHandler *ff_rtp_handler_find_by_name(const char *name, diff --git a/libavformat/rtpdec_formats.h b/libavformat/rtpdec_formats.h index 708c2996d6..3074565db7 100644 --- a/libavformat/rtpdec_formats.h +++ b/libavformat/rtpdec_formats.h @@ -33,6 +33,10 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p); extern RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler; extern RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler; +extern RTPDynamicProtocolHandler ff_g726_16_dynamic_handler; +extern RTPDynamicProtocolHandler ff_g726_24_dynamic_handler; +extern RTPDynamicProtocolHandler ff_g726_32_dynamic_handler; +extern RTPDynamicProtocolHandler ff_g726_40_dynamic_handler; extern RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler; extern RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler; extern RTPDynamicProtocolHandler ff_h264_dynamic_handler; diff --git a/libavformat/rtpdec_g726.c b/libavformat/rtpdec_g726.c new file mode 100644 index 0000000000..0b7b0f0f94 --- /dev/null +++ b/libavformat/rtpdec_g726.c @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2011 Miroslav Slugeň + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avformat.h" +#include "rtpdec_formats.h" + +static int g726_16_init(AVFormatContext *s, int st_index, PayloadContext *data) +{ + AVStream *stream = s->streams[st_index]; + AVCodecContext *codec = stream->codec; + + codec->bit_rate = 16000; + if (codec->sample_rate) + codec->bits_per_coded_sample = + av_clip((codec->bit_rate + codec->sample_rate/2) / codec->sample_rate, 2, 5); + + return 0; +} + +static int g726_24_init(AVFormatContext *s, int st_index, PayloadContext *data) +{ + AVStream *stream = s->streams[st_index]; + AVCodecContext *codec = stream->codec; + + codec->bit_rate = 24000; + if (codec->sample_rate) + codec->bits_per_coded_sample = + av_clip((codec->bit_rate + codec->sample_rate/2) / codec->sample_rate, 2, 5); + + return 0; +} + +static int g726_32_init(AVFormatContext *s, int st_index, PayloadContext *data) +{ + AVStream *stream = s->streams[st_index]; + AVCodecContext *codec = stream->codec; + + codec->bit_rate = 32000; + if (codec->sample_rate) + codec->bits_per_coded_sample = + av_clip((codec->bit_rate + codec->sample_rate/2) / codec->sample_rate, 2, 5); + + return 0; +} + +static int g726_40_init(AVFormatContext *s, int st_index, PayloadContext *data) +{ + AVStream *stream = s->streams[st_index]; + AVCodecContext *codec = stream->codec; + + codec->bit_rate = 40000; + if (codec->sample_rate) + codec->bits_per_coded_sample = + av_clip((codec->bit_rate + codec->sample_rate/2) / codec->sample_rate, 2, 5); + + return 0; +} + +RTPDynamicProtocolHandler ff_g726_16_dynamic_handler = { + .enc_name = "G726-16", + .codec_type = AVMEDIA_TYPE_AUDIO, + .codec_id = CODEC_ID_ADPCM_G726, + .init = g726_16_init, +}; + +RTPDynamicProtocolHandler ff_g726_24_dynamic_handler = { + .enc_name = "G726-24", + .codec_type = AVMEDIA_TYPE_AUDIO, + .codec_id = CODEC_ID_ADPCM_G726, + .init = g726_24_init, +}; + +RTPDynamicProtocolHandler ff_g726_32_dynamic_handler = { + .enc_name = "G726-32", + .codec_type = AVMEDIA_TYPE_AUDIO, + .codec_id = CODEC_ID_ADPCM_G726, + .init = g726_32_init, +}; + +RTPDynamicProtocolHandler ff_g726_40_dynamic_handler = { + .enc_name = "G726-40", + .codec_type = AVMEDIA_TYPE_AUDIO, + .codec_id = CODEC_ID_ADPCM_G726, + .init = g726_40_init, +}; From c3f9ebf74371b63fba0e7491e61904bbd165cd0f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 29 Nov 2011 19:28:15 +0100 Subject: [PATCH 09/11] lavf: make av_set_pts_info private. It's supposed to be called only from (de)muxers. --- libavdevice/alsa-audio-dec.c | 3 ++- libavdevice/bktr.c | 3 ++- libavdevice/fbdev.c | 3 ++- libavdevice/jack_audio.c | 3 ++- libavdevice/libcdio.c | 2 +- libavdevice/libdc1394.c | 3 ++- libavdevice/oss_audio.c | 3 ++- libavdevice/pulse.c | 3 ++- libavdevice/sndio_dec.c | 3 ++- libavdevice/v4l.c | 3 ++- libavdevice/v4l2.c | 3 ++- libavdevice/vfwcap.c | 3 ++- libavdevice/x11grab.c | 3 ++- libavformat/4xm.c | 5 +++-- libavformat/aacdec.c | 3 ++- libavformat/adxdec.c | 3 ++- libavformat/aiffdec.c | 3 ++- libavformat/aiffenc.c | 3 ++- libavformat/amr.c | 3 ++- libavformat/anm.c | 3 ++- libavformat/ape.c | 3 ++- libavformat/asfdec.c | 3 ++- libavformat/asfenc.c | 3 ++- libavformat/assdec.c | 2 +- libavformat/au.c | 3 ++- libavformat/avformat.h | 12 ++++-------- libavformat/avidec.c | 5 +++-- libavformat/avienc.c | 3 ++- libavformat/avisynth.c | 3 ++- libavformat/bethsoftvid.c | 3 ++- libavformat/bfi.c | 5 +++-- libavformat/bink.c | 5 +++-- libavformat/bmv.c | 5 +++-- libavformat/c93.c | 3 ++- libavformat/cafdec.c | 3 ++- libavformat/cdg.c | 3 ++- libavformat/dfa.c | 3 ++- libavformat/dsicin.c | 5 +++-- libavformat/dv.c | 5 +++-- libavformat/dxa.c | 3 ++- libavformat/eacdata.c | 3 ++- libavformat/electronicarts.c | 3 ++- libavformat/ffmdec.c | 3 ++- libavformat/ffmenc.c | 3 ++- libavformat/filmstripdec.c | 3 ++- libavformat/flacdec.c | 3 ++- libavformat/flic.c | 11 ++++++----- libavformat/flvdec.c | 3 ++- libavformat/flvenc.c | 2 +- libavformat/gsmdec.c | 3 ++- libavformat/gxf.c | 2 +- libavformat/gxfenc.c | 5 +++-- libavformat/idcin.c | 5 +++-- libavformat/idroqdec.c | 5 +++-- libavformat/iff.c | 3 ++- libavformat/img2.c | 2 +- libavformat/internal.h | 13 +++++++++++++ libavformat/ipmovie.c | 5 +++-- libavformat/iss.c | 3 ++- libavformat/iv8.c | 3 ++- libavformat/ivfdec.c | 3 ++- libavformat/jvdec.c | 5 +++-- libavformat/libnut.c | 5 +++-- libavformat/lmlm4.c | 3 ++- libavformat/lxfdec.c | 7 ++++--- libavformat/matroskadec.c | 2 +- libavformat/matroskaenc.c | 3 ++- libavformat/mm.c | 5 +++-- libavformat/mmf.c | 5 +++-- libavformat/mov.c | 3 ++- libavformat/movenc.c | 2 +- libavformat/mp3dec.c | 3 ++- libavformat/mpc.c | 3 ++- libavformat/mpc8.c | 3 ++- libavformat/mpegenc.c | 3 ++- libavformat/mpegts.c | 8 ++++---- libavformat/mpegtsenc.c | 2 +- libavformat/msnwc_tcp.c | 3 ++- libavformat/mtv.c | 5 +++-- libavformat/mvi.c | 5 +++-- libavformat/mxfdec.c | 2 +- libavformat/mxfenc.c | 4 ++-- libavformat/mxg.c | 5 +++-- libavformat/ncdec.c | 3 ++- libavformat/nsvdec.c | 5 +++-- libavformat/nutdec.c | 2 +- libavformat/nutenc.c | 2 +- libavformat/nuv.c | 5 +++-- libavformat/oggdec.c | 2 +- libavformat/oggenc.c | 4 ++-- libavformat/oggparsecelt.c | 3 ++- libavformat/oggparsedirac.c | 5 +++-- libavformat/oggparseflac.c | 3 ++- libavformat/oggparseogm.c | 5 +++-- libavformat/oggparseskeleton.c | 3 ++- libavformat/oggparsespeex.c | 3 ++- libavformat/oggparsetheora.c | 3 ++- libavformat/oggparsevorbis.c | 2 +- libavformat/oma.c | 5 +++-- libavformat/psxstr.c | 5 +++-- libavformat/pva.c | 5 +++-- libavformat/r3d.c | 5 +++-- libavformat/rawdec.c | 7 ++++--- libavformat/rl2.c | 5 +++-- libavformat/rmdec.c | 3 ++- libavformat/rpl.c | 5 +++-- libavformat/rsodec.c | 2 +- libavformat/rtpdec_asf.c | 3 ++- libavformat/rtpdec_qt.c | 3 ++- libavformat/rtpenc.c | 6 +++--- libavformat/rtsp.c | 6 +++--- libavformat/segafilm.c | 3 ++- libavformat/sierravmd.c | 7 ++++--- libavformat/siff.c | 5 +++-- libavformat/smacker.c | 5 +++-- libavformat/sol.c | 3 ++- libavformat/soxdec.c | 3 ++- libavformat/srtdec.c | 2 +- libavformat/swfdec.c | 6 +++--- libavformat/thp.c | 5 +++-- libavformat/tiertexseq.c | 5 +++-- libavformat/tmv.c | 5 +++-- libavformat/tta.c | 3 ++- libavformat/tty.c | 3 ++- libavformat/utils.c | 10 +++++++++- libavformat/vc1test.c | 5 +++-- libavformat/vc1testenc.c | 3 ++- libavformat/version.h | 3 +++ libavformat/vqf.c | 3 ++- libavformat/wav.c | 7 ++++--- libavformat/wc3movie.c | 5 +++-- libavformat/westwood.c | 7 ++++--- libavformat/wtv.c | 2 +- libavformat/wv.c | 3 ++- libavformat/xa.c | 3 ++- libavformat/xmv.c | 5 +++-- libavformat/xwma.c | 3 ++- libavformat/yop.c | 3 ++- libavformat/yuv4mpeg.c | 3 ++- 139 files changed, 338 insertions(+), 205 deletions(-) diff --git a/libavdevice/alsa-audio-dec.c b/libavdevice/alsa-audio-dec.c index 1346016254..5344b1988d 100644 --- a/libavdevice/alsa-audio-dec.c +++ b/libavdevice/alsa-audio-dec.c @@ -47,6 +47,7 @@ #include #include "libavformat/avformat.h" +#include "libavformat/internal.h" #include "libavutil/opt.h" #include "alsa-audio.h" @@ -102,7 +103,7 @@ static av_cold int audio_read_header(AVFormatContext *s1, st->codec->codec_id = codec_id; st->codec->sample_rate = s->sample_rate; st->codec->channels = s->channels; - av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ return 0; diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index 1a8562c016..e6a1e8ba2d 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -25,6 +25,7 @@ */ #include "libavformat/avformat.h" +#include "libavformat/internal.h" #include "libavutil/log.h" #include "libavutil/opt.h" #include "libavutil/parseutils.h" @@ -275,7 +276,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) ret = AVERROR(ENOMEM); goto out; } - av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */ + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */ s->width = width; s->height = height; diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c index ddace67392..7444f47e57 100644 --- a/libavdevice/fbdev.c +++ b/libavdevice/fbdev.c @@ -43,6 +43,7 @@ #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" #include "libavformat/avformat.h" +#include "libavformat/internal.h" struct rgb_pixfmt_map_entry { int bits_per_pixel; @@ -110,7 +111,7 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, if (!(st = avformat_new_stream(avctx, NULL))) return AVERROR(ENOMEM); - av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in microseconds */ + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in microseconds */ /* NONBLOCK is ignored by the fbdev driver, only set for consistency */ if (avctx->flags & AVFMT_FLAG_NONBLOCK) diff --git a/libavdevice/jack_audio.c b/libavdevice/jack_audio.c index f75c176be9..dbe1771ebf 100644 --- a/libavdevice/jack_audio.c +++ b/libavdevice/jack_audio.c @@ -29,6 +29,7 @@ #include "libavutil/opt.h" #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" +#include "libavformat/internal.h" #include "timefilter.h" /** @@ -244,7 +245,7 @@ static int audio_read_header(AVFormatContext *context, AVFormatParameters *param stream->codec->sample_rate = self->sample_rate; stream->codec->channels = self->nports; - av_set_pts_info(stream, 64, 1, 1000000); /* 64 bits pts in us */ + avpriv_set_pts_info(stream, 64, 1, 1000000); /* 64 bits pts in us */ return 0; } diff --git a/libavdevice/libcdio.c b/libavdevice/libcdio.c index 6d0671a609..e00272c115 100644 --- a/libavdevice/libcdio.c +++ b/libavdevice/libcdio.c @@ -92,7 +92,7 @@ static av_cold int read_header(AVFormatContext *ctx, AVFormatParameters *ap) st->duration = s->drive->audio_last_sector - s->drive->audio_first_sector; else if (s->drive->tracks) st->duration = s->drive->disc_toc[s->drive->tracks].dwStartSector; - av_set_pts_info(st, 64, CDIO_CD_FRAMESIZE_RAW, 2*st->codec->channels*st->codec->sample_rate); + avpriv_set_pts_info(st, 64, CDIO_CD_FRAMESIZE_RAW, 2*st->codec->channels*st->codec->sample_rate); for (i = 0; i < s->drive->tracks; i++) { char title[16]; diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c index bca014fe3c..71f08b137d 100644 --- a/libavdevice/libdc1394.c +++ b/libavdevice/libdc1394.c @@ -22,6 +22,7 @@ #include "config.h" #include "libavformat/avformat.h" +#include "libavformat/internal.h" #include "libavutil/log.h" #include "libavutil/mathematics.h" #include "libavutil/opt.h" @@ -165,7 +166,7 @@ static inline int dc1394_read_common(AVFormatContext *c, AVFormatParameters *ap, ret = AVERROR(ENOMEM); goto out; } - av_set_pts_info(vst, 64, 1, 1000); + avpriv_set_pts_info(vst, 64, 1, 1000); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = CODEC_ID_RAWVIDEO; vst->codec->time_base.den = framerate.num; diff --git a/libavdevice/oss_audio.c b/libavdevice/oss_audio.c index 01d944a163..308fc0df97 100644 --- a/libavdevice/oss_audio.c +++ b/libavdevice/oss_audio.c @@ -40,6 +40,7 @@ #include "libavutil/opt.h" #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" +#include "libavformat/internal.h" #define AUDIO_BLOCK_SIZE 4096 @@ -225,7 +226,7 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap) st->codec->sample_rate = s->sample_rate; st->codec->channels = s->channels; - av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ return 0; } diff --git a/libavdevice/pulse.c b/libavdevice/pulse.c index 41f88b541f..7f7c6dc2ff 100644 --- a/libavdevice/pulse.c +++ b/libavdevice/pulse.c @@ -31,6 +31,7 @@ #include #include "libavformat/avformat.h" +#include "libavformat/internal.h" #include "libavutil/opt.h" #define DEFAULT_CODEC_ID AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE) @@ -108,7 +109,7 @@ static av_cold int pulse_read_header(AVFormatContext *s, st->codec->codec_id = codec_id; st->codec->sample_rate = pd->sample_rate; st->codec->channels = pd->channels; - av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ pd->pts = AV_NOPTS_VALUE; pd->frame_duration = (pd->frame_size * 1000000LL * 8) / diff --git a/libavdevice/sndio_dec.c b/libavdevice/sndio_dec.c index ca11661f09..cc74c38a39 100644 --- a/libavdevice/sndio_dec.c +++ b/libavdevice/sndio_dec.c @@ -23,6 +23,7 @@ #include #include "libavformat/avformat.h" +#include "libavformat/internal.h" #include "libavutil/opt.h" #include "sndio_common.h" @@ -48,7 +49,7 @@ static av_cold int audio_read_header(AVFormatContext *s1, st->codec->sample_rate = s->sample_rate; st->codec->channels = s->channels; - av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ return 0; } diff --git a/libavdevice/v4l.c b/libavdevice/v4l.c index d848e2b645..bdfee2df4e 100644 --- a/libavdevice/v4l.c +++ b/libavdevice/v4l.c @@ -30,6 +30,7 @@ #include "libavutil/log.h" #include "libavutil/opt.h" #include "libavformat/avformat.h" +#include "libavformat/internal.h" #include "libavcodec/dsputil.h" #include #include @@ -100,7 +101,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) st = avformat_new_stream(s1, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ video_fd = open(s1->filename, O_RDWR); if (video_fd < 0) { diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 372d0901cc..0c61f46b53 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -30,6 +30,7 @@ #undef __STRICT_ANSI__ //workaround due to broken kernel headers #include "config.h" #include "libavformat/avformat.h" +#include "libavformat/internal.h" #include #include #include @@ -585,7 +586,7 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap) res = AVERROR(ENOMEM); goto out; } - av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ if (s->video_size && (res = av_parse_video_size(&s->width, &s->height, s->video_size)) < 0) { av_log(s1, AV_LOG_ERROR, "Could not parse video size '%s'.\n", s->video_size); diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c index 6f11914935..b5baee3b79 100644 --- a/libavdevice/vfwcap.c +++ b/libavdevice/vfwcap.c @@ -20,6 +20,7 @@ */ #include "libavformat/avformat.h" +#include "libavformat/internal.h" #include "libavutil/log.h" #include "libavutil/opt.h" #include "libavutil/parseutils.h" @@ -396,7 +397,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) } } - av_set_pts_info(st, 32, 1, 1000); + avpriv_set_pts_info(st, 32, 1, 1000); ctx->mutex = CreateMutex(NULL, 0, NULL); if(!ctx->mutex) { diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index 7874b81908..5673e5e611 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -37,6 +37,7 @@ #include "config.h" #include "libavformat/avformat.h" +#include "libavformat/internal.h" #include "libavutil/log.h" #include "libavutil/opt.h" #include "libavutil/parseutils.h" @@ -198,7 +199,7 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) ret = AVERROR(ENOMEM); goto out; } - av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ screen = DefaultScreen(dpy); diff --git a/libavformat/4xm.c b/libavformat/4xm.c index ba4eda351d..6dc919e1bf 100644 --- a/libavformat/4xm.c +++ b/libavformat/4xm.c @@ -30,6 +30,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/intfloat_readwrite.h" #include "avformat.h" +#include "internal.h" #define RIFF_TAG MKTAG('R', 'I', 'F', 'F') #define FOURXMV_TAG MKTAG('4', 'X', 'M', 'V') @@ -146,7 +147,7 @@ static int fourxm_read_header(AVFormatContext *s, ret= AVERROR(ENOMEM); goto fail; } - av_set_pts_info(st, 60, 1, fourxm->fps); + avpriv_set_pts_info(st, 60, 1, fourxm->fps); fourxm->video_stream_index = st->index; @@ -205,7 +206,7 @@ static int fourxm_read_header(AVFormatContext *s, } st->id = current_track; - av_set_pts_info(st, 60, 1, fourxm->tracks[current_track].sample_rate); + avpriv_set_pts_info(st, 60, 1, fourxm->tracks[current_track].sample_rate); fourxm->tracks[current_track].stream_index = st->index; diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index 4aa2d32754..25c59108fe 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #include "rawdec.h" #include "id3v1.h" @@ -76,7 +77,7 @@ static int adts_aac_read_header(AVFormatContext *s, ff_id3v1_read(s); //LCM of all possible ADTS sample rates - av_set_pts_info(st, 64, 1, 28224000); + avpriv_set_pts_info(st, 64, 1, 28224000); return 0; } diff --git a/libavformat/adxdec.c b/libavformat/adxdec.c index eff26982ea..dca9748301 100644 --- a/libavformat/adxdec.c +++ b/libavformat/adxdec.c @@ -26,6 +26,7 @@ #include "libavutil/intreadwrite.h" #include "libavcodec/adx.h" #include "avformat.h" +#include "internal.h" #define BLOCK_SIZE 18 #define BLOCK_SAMPLES 32 @@ -95,7 +96,7 @@ static int adx_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = s->iformat->value; - av_set_pts_info(st, 64, BLOCK_SAMPLES, avctx->sample_rate); + avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, avctx->sample_rate); return 0; } diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 5d25a742a1..f54a7ffafe 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -22,6 +22,7 @@ #include "libavutil/intfloat_readwrite.h" #include "libavutil/dict.h" #include "avformat.h" +#include "internal.h" #include "pcm.h" #include "aiff.h" @@ -268,7 +269,7 @@ static int aiff_read_header(AVFormatContext *s, got_sound: /* Now positioned, get the sound data start and end */ - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); st->start_time = 0; st->duration = st->codec->frame_size ? st->nb_frames * st->codec->frame_size : st->nb_frames; diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index fbe1491e78..df43688d40 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -21,6 +21,7 @@ #include "libavutil/intfloat_readwrite.h" #include "avformat.h" +#include "internal.h" #include "aiff.h" #include "avio_internal.h" @@ -96,7 +97,7 @@ static int aiff_write_header(AVFormatContext *s) avio_wb32(pb, 0); /* Data offset */ avio_wb32(pb, 0); /* Block-size (block align) */ - av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate); + avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate); /* Data is starting here */ avio_flush(pb); diff --git a/libavformat/amr.c b/libavformat/amr.c index 0f62c7dfa5..b52ac49128 100644 --- a/libavformat/amr.c +++ b/libavformat/amr.c @@ -26,6 +26,7 @@ Only mono files are supported. */ #include "avformat.h" +#include "internal.h" static const char AMR_header [] = "#!AMR\n"; static const char AMRWB_header [] = "#!AMR-WB\n"; @@ -111,7 +112,7 @@ static int amr_read_header(AVFormatContext *s, } st->codec->channels = 1; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); return 0; } diff --git a/libavformat/anm.c b/libavformat/anm.c index a89bf3e719..00a36abebe 100644 --- a/libavformat/anm.c +++ b/libavformat/anm.c @@ -26,6 +26,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" typedef struct { int base_record; @@ -128,7 +129,7 @@ static int read_header(AVFormatContext *s, avio_skip(pb, 32); /* record_types */ st->nb_frames = avio_rl32(pb); - av_set_pts_info(st, 64, 1, avio_rl16(pb)); + avpriv_set_pts_info(st, 64, 1, avio_rl16(pb)); avio_skip(pb, 58); /* color cycling and palette data */ diff --git a/libavformat/ape.c b/libavformat/ape.c index b29e57bcce..a60626e133 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -24,6 +24,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #include "apetag.h" /* The earliest and latest file formats supported by this library */ @@ -330,7 +331,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) st->nb_frames = ape->totalframes; st->start_time = 0; st->duration = total_blocks / MAC_SUBFRAME_SIZE; - av_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate); + avpriv_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate); st->codec->extradata = av_malloc(APE_EXTRADATA_SIZE); st->codec->extradata_size = APE_EXTRADATA_SIZE; diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 02453407b5..4c9c59d606 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -28,6 +28,7 @@ #include "libavutil/mathematics.h" #include "libavcodec/mpegaudio.h" #include "avformat.h" +#include "internal.h" #include "avio_internal.h" #include "riff.h" #include "asf.h" @@ -230,7 +231,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size) st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */ + avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */ asf_st = av_mallocz(sizeof(ASFStream)); if (!asf_st) return AVERROR(ENOMEM); diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index 01f98d2a6f..1cfc857418 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avformat.h" +#include "internal.h" #include "riff.h" #include "asf.h" #include "avio_internal.h" @@ -321,7 +322,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data for(n=0;nnb_streams;n++) { enc = s->streams[n]->codec; - av_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */ + avpriv_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */ bit_rate += enc->bit_rate; } diff --git a/libavformat/assdec.c b/libavformat/assdec.c index 6b9c3dea95..b100f2c5d1 100644 --- a/libavformat/assdec.c +++ b/libavformat/assdec.c @@ -86,7 +86,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) st = avformat_new_stream(s, NULL); if (!st) return -1; - av_set_pts_info(st, 64, 1, 100); + avpriv_set_pts_info(st, 64, 1, 100); st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codec->codec_id= CODEC_ID_SSA; diff --git a/libavformat/au.c b/libavformat/au.c index 4f7677347b..c6fb8dbaa9 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -28,6 +28,7 @@ */ #include "avformat.h" +#include "internal.h" #include "avio_internal.h" #include "pcm.h" #include "riff.h" @@ -159,7 +160,7 @@ static int au_read_header(AVFormatContext *s, st->codec->codec_id = codec; st->codec->channels = channels; st->codec->sample_rate = rate; - av_set_pts_info(st, 64, 1, rate); + avpriv_set_pts_info(st, 64, 1, rate); return 0; } diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 5276af1c15..367ba1e75b 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1540,18 +1540,14 @@ AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c); AVProgram *av_new_program(AVFormatContext *s, int id); +#if FF_API_SET_PTS_INFO /** - * Set the pts for a given stream. If the new values would be invalid - * (<= 0), it leaves the AVStream unchanged. - * - * @param s stream - * @param pts_wrap_bits number of bits effectively used by the pts - * (used for wrap control, 33 is the value for MPEG) - * @param pts_num numerator to convert to seconds (MPEG: 1) - * @param pts_den denominator to convert to seconds (MPEG: 90000) + * @deprecated this function is not supposed to be called outside of lavf */ +attribute_deprecated void av_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den); +#endif #define AVSEEK_FLAG_BACKWARD 1 ///< seek backward #define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes diff --git a/libavformat/avidec.c b/libavformat/avidec.c index ee4265538e..ad35995b05 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -25,6 +25,7 @@ #include "libavutil/dict.h" #include "libavutil/avstring.h" #include "avformat.h" +#include "internal.h" #include "avi.h" #include "dv.h" #include "riff.h" @@ -502,7 +503,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) ast->scale = 1; } } - av_set_pts_info(st, 64, ast->scale, ast->rate); + avpriv_set_pts_info(st, 64, ast->scale, ast->rate); ast->cum_len=avio_rl32(pb); /* start */ st->nb_frames = avio_rl32(pb); @@ -784,7 +785,7 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt) { *st->codec = *ast->sub_ctx->streams[0]->codec; ast->sub_ctx->streams[0]->codec->extradata = NULL; time_base = ast->sub_ctx->streams[0]->time_base; - av_set_pts_info(st, 64, time_base.num, time_base.den); + avpriv_set_pts_info(st, 64, time_base.num, time_base.den); } ast->sub_buffer = pkt->data; memset(pkt, 0, sizeof(*pkt)); diff --git a/libavformat/avienc.c b/libavformat/avienc.c index b4521cd6ef..2a23c213b6 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avformat.h" +#include "internal.h" #include "avi.h" #include "avio_internal.h" #include "riff.h" @@ -256,7 +257,7 @@ static int avi_write_header(AVFormatContext *s) avio_wl32(pb, au_scale); /* scale */ avio_wl32(pb, au_byterate); /* rate */ - av_set_pts_info(s->streams[i], 64, au_scale, au_byterate); + avpriv_set_pts_info(s->streams[i], 64, au_scale, au_byterate); avio_wl32(pb, 0); /* start */ avist->frames_hdr_strm = avio_tell(pb); /* remember this offset to fill later */ diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 01fe1752e4..9449c1b608 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "internal.h" #include "riff.h" #include @@ -137,7 +138,7 @@ static int avisynth_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->stream_codec_tag = stream->info.fccHandler; - av_set_pts_info(st, 64, info.dwScale, info.dwRate); + avpriv_set_pts_info(st, 64, info.dwScale, info.dwRate); st->start_time = stream->info.dwStart; } } diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c index d30f873e9a..7705fcb5f6 100644 --- a/libavformat/bethsoftvid.c +++ b/libavformat/bethsoftvid.c @@ -29,6 +29,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #include "libavcodec/bethsoftvideo.h" typedef struct BVID_DemuxContext @@ -73,7 +74,7 @@ static int vid_read_header(AVFormatContext *s, stream = avformat_new_stream(s, NULL); if (!stream) return AVERROR(ENOMEM); - av_set_pts_info(stream, 32, 1, 60); // 16 ms increments, i.e. 60 fps + avpriv_set_pts_info(stream, 32, 1, 60); // 16 ms increments, i.e. 60 fps stream->codec->codec_type = AVMEDIA_TYPE_VIDEO; stream->codec->codec_id = CODEC_ID_BETHSOFTVID; stream->codec->width = avio_rl16(pb); diff --git a/libavformat/bfi.c b/libavformat/bfi.c index 647dd54894..bb02e85581 100644 --- a/libavformat/bfi.c +++ b/libavformat/bfi.c @@ -28,6 +28,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" typedef struct BFIContext { int nframes; @@ -86,7 +87,7 @@ static int bfi_read_header(AVFormatContext * s, AVFormatParameters * ap) astream->codec->sample_rate = avio_rl32(pb); /* Set up the video codec... */ - av_set_pts_info(vstream, 32, 1, fps); + avpriv_set_pts_info(vstream, 32, 1, fps); vstream->codec->codec_type = AVMEDIA_TYPE_VIDEO; vstream->codec->codec_id = CODEC_ID_BFI; vstream->codec->pix_fmt = PIX_FMT_PAL8; @@ -99,7 +100,7 @@ static int bfi_read_header(AVFormatContext * s, AVFormatParameters * ap) astream->codec->bit_rate = astream->codec->sample_rate * astream->codec->bits_per_coded_sample; avio_seek(pb, chunk_header - 3, SEEK_SET); - av_set_pts_info(astream, 64, 1, astream->codec->sample_rate); + avpriv_set_pts_info(astream, 64, 1, astream->codec->sample_rate); return 0; } diff --git a/libavformat/bink.c b/libavformat/bink.c index ea04afdf92..ecf6905843 100644 --- a/libavformat/bink.c +++ b/libavformat/bink.c @@ -30,6 +30,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" enum BinkAudFlags { BINK_AUD_16BITS = 0x4000, ///< prefer 16-bit output @@ -109,7 +110,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) av_log(s, AV_LOG_ERROR, "invalid header: invalid fps (%d/%d)\n", fps_num, fps_den); return AVERROR(EIO); } - av_set_pts_info(vst, 64, fps_den, fps_num); + avpriv_set_pts_info(vst, 64, fps_den, fps_num); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = CODEC_ID_BINKVIDEO; @@ -136,7 +137,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_tag = 0; ast->codec->sample_rate = avio_rl16(pb); - av_set_pts_info(ast, 64, 1, ast->codec->sample_rate); + avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate); flags = avio_rl16(pb); ast->codec->codec_id = flags & BINK_AUD_USEDCT ? CODEC_ID_BINKAUDIO_DCT : CODEC_ID_BINKAUDIO_RDFT; diff --git a/libavformat/bmv.c b/libavformat/bmv.c index fb41712868..1077efa573 100644 --- a/libavformat/bmv.c +++ b/libavformat/bmv.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "internal.h" enum BMVFlags { BMV_NOP = 0, @@ -50,7 +51,7 @@ static int bmv_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->width = 640; st->codec->height = 429; st->codec->pix_fmt = PIX_FMT_PAL8; - av_set_pts_info(st, 16, 1, 12); + avpriv_set_pts_info(st, 16, 1, 12); ast = avformat_new_stream(s, 0); if (!ast) return AVERROR(ENOMEM); @@ -58,7 +59,7 @@ static int bmv_read_header(AVFormatContext *s, AVFormatParameters *ap) ast->codec->codec_id = CODEC_ID_BMV_AUDIO; ast->codec->channels = 2; ast->codec->sample_rate = 22050; - av_set_pts_info(ast, 16, 1, 22050); + avpriv_set_pts_info(ast, 16, 1, 22050); c->get_next = 1; c->audio_pos = 0; diff --git a/libavformat/c93.c b/libavformat/c93.c index a47c301a36..d82086d296 100644 --- a/libavformat/c93.c +++ b/libavformat/c93.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "internal.h" #include "voc.h" #include "libavutil/intreadwrite.h" @@ -89,7 +90,7 @@ static int read_header(AVFormatContext *s, video->codec->height = 192; /* 4:3 320x200 with 8 empty lines */ video->sample_aspect_ratio = (AVRational) { 5, 6 }; - av_set_pts_info(video, 64, 2, 25); + avpriv_set_pts_info(video, 64, 2, 25); video->nb_frames = framecount; video->duration = framecount; video->start_time = 0; diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index b8c378a48e..36d7ad431d 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -26,6 +26,7 @@ */ #include "avformat.h" +#include "internal.h" #include "riff.h" #include "isom.h" #include "libavutil/intreadwrite.h" @@ -287,7 +288,7 @@ static int read_header(AVFormatContext *s, return AVERROR_INVALIDDATA; } - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); st->start_time = 0; /* position the stream at the start of data */ diff --git a/libavformat/cdg.c b/libavformat/cdg.c index b6caa5129d..0980df7ebf 100644 --- a/libavformat/cdg.c +++ b/libavformat/cdg.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "internal.h" #define CDG_PACKET_SIZE 24 #define CDG_COMMAND 0x09 @@ -38,7 +39,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) vst->codec->codec_id = CODEC_ID_CDGRAPHICS; /// 75 sectors/sec * 4 packets/sector = 300 packets/sec - av_set_pts_info(vst, 32, 1, 300); + avpriv_set_pts_info(vst, 32, 1, 300); ret = avio_size(s->pb); if (ret > 0) diff --git a/libavformat/dfa.c b/libavformat/dfa.c index 7b90ba7805..ac49b6104b 100644 --- a/libavformat/dfa.c +++ b/libavformat/dfa.c @@ -21,6 +21,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" static int dfa_probe(AVProbeData *p) { @@ -58,7 +59,7 @@ static int dfa_read_header(AVFormatContext *s, av_log(s, AV_LOG_WARNING, "Zero FPS reported, defaulting to 10\n"); mspf = 100; } - av_set_pts_info(st, 24, mspf, 1000); + avpriv_set_pts_info(st, 24, mspf, 1000); avio_skip(pb, 128 - 16); // padding st->duration = frames; diff --git a/libavformat/dsicin.c b/libavformat/dsicin.c index 5f02f79501..801ca6af22 100644 --- a/libavformat/dsicin.c +++ b/libavformat/dsicin.c @@ -26,6 +26,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" typedef struct CinFileHeader { @@ -111,7 +112,7 @@ static int cin_read_header(AVFormatContext *s, AVFormatParameters *ap) if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 32, 1, 12); + avpriv_set_pts_info(st, 32, 1, 12); cin->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_DSICINVIDEO; @@ -124,7 +125,7 @@ static int cin_read_header(AVFormatContext *s, AVFormatParameters *ap) if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 32, 1, 22050); + avpriv_set_pts_info(st, 32, 1, 22050); cin->audio_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_DSICINAUDIO; diff --git a/libavformat/dv.c b/libavformat/dv.c index 21823752f5..805f25271c 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -30,6 +30,7 @@ */ #include #include "avformat.h" +#include "internal.h" #include "libavcodec/dvdata.h" #include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" @@ -214,7 +215,7 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame) c->ast[i] = avformat_new_stream(c->fctx, NULL); if (!c->ast[i]) break; - av_set_pts_info(c->ast[i], 64, 1, 30000); + avpriv_set_pts_info(c->ast[i], 64, 1, 30000); c->ast[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO; c->ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE; @@ -244,7 +245,7 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame) if (c->sys) { avctx = c->vst->codec; - av_set_pts_info(c->vst, 64, c->sys->time_base.num, + avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num, c->sys->time_base.den); avctx->time_base= c->sys->time_base; if (!avctx->width){ diff --git a/libavformat/dxa.c b/libavformat/dxa.c index e35740eff9..0cc803d7bf 100644 --- a/libavformat/dxa.c +++ b/libavformat/dxa.c @@ -21,6 +21,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #include "riff.h" #define DXA_EXTRA_SIZE 9 @@ -127,7 +128,7 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->width = w; st->codec->height = h; av_reduce(&den, &num, den, num, (1UL<<31)-1); - av_set_pts_info(st, 33, num, den); + avpriv_set_pts_info(st, 33, num, den); /* flags & 0x80 means that image is interlaced, * flags & 0x40 means that image has double height * either way set true height diff --git a/libavformat/eacdata.c b/libavformat/eacdata.c index 7d6da93efc..8fe144e6a9 100644 --- a/libavformat/eacdata.c +++ b/libavformat/eacdata.c @@ -29,6 +29,7 @@ */ #include "avformat.h" +#include "internal.h" typedef struct { unsigned int channels; @@ -72,7 +73,7 @@ static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->codec_id = CODEC_ID_ADPCM_EA_XAS; st->codec->channels = cdata->channels; st->codec->sample_rate = sample_rate; - av_set_pts_info(st, 64, 1, sample_rate); + avpriv_set_pts_info(st, 64, 1, sample_rate); cdata->audio_pts = 0; return 0; diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c index c236d2fbbf..0facc8afba 100644 --- a/libavformat/electronicarts.c +++ b/libavformat/electronicarts.c @@ -27,6 +27,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define SCHl_TAG MKTAG('S', 'C', 'H', 'l') #define SEAD_TAG MKTAG('S', 'E', 'A', 'D') /* Sxxx header */ @@ -438,7 +439,7 @@ static int ea_read_header(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 33, 1, ea->sample_rate); + avpriv_set_pts_info(st, 33, 1, ea->sample_rate); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = ea->audio_codec; st->codec->codec_tag = 0; /* no tag */ diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index 61b6a2dafe..114576707e 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/intfloat_readwrite.h" #include "avformat.h" +#include "internal.h" #include "ffm.h" #if CONFIG_AVSERVER #include @@ -294,7 +295,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) if (!st) goto fail; - av_set_pts_info(st, 64, 1, 1000000); + avpriv_set_pts_info(st, 64, 1, 1000000); codec = st->codec; /* generic info */ diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c index 4bfae693e5..af32e71b7d 100644 --- a/libavformat/ffmenc.c +++ b/libavformat/ffmenc.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/intfloat_readwrite.h" #include "avformat.h" +#include "internal.h" #include "ffm.h" static void flush_packet(AVFormatContext *s) @@ -107,7 +108,7 @@ static int ffm_write_header(AVFormatContext *s) /* list of streams */ for(i=0;inb_streams;i++) { st = s->streams[i]; - av_set_pts_info(st, 64, 1, 1000000); + avpriv_set_pts_info(st, 64, 1, 1000000); codec = st->codec; /* generic info */ diff --git a/libavformat/filmstripdec.c b/libavformat/filmstripdec.c index 8028d0404f..648fb4f384 100644 --- a/libavformat/filmstripdec.c +++ b/libavformat/filmstripdec.c @@ -26,6 +26,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define RAND_TAG MKBETAG('R','a','n','d') @@ -67,7 +68,7 @@ static int read_header(AVFormatContext *s, st->codec->width = avio_rb16(pb); st->codec->height = avio_rb16(pb); film->leading = avio_rb16(pb); - av_set_pts_info(st, 64, 1, avio_rb16(pb)); + avpriv_set_pts_info(st, 64, 1, avio_rb16(pb)); avio_seek(pb, 0, SEEK_SET); diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index 41912854b7..c5a6ac9b43 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -21,6 +21,7 @@ #include "libavcodec/flac.h" #include "avformat.h" +#include "internal.h" #include "rawdec.h" #include "oggdec.h" #include "vorbiscomment.h" @@ -91,7 +92,7 @@ static int flac_read_header(AVFormatContext *s, /* set time base and duration */ if (si.samplerate > 0) { - av_set_pts_info(st, 64, 1, si.samplerate); + avpriv_set_pts_info(st, 64, 1, si.samplerate); if (si.samples > 0) st->duration = si.samples; } diff --git a/libavformat/flic.c b/libavformat/flic.c index 39c7444964..7edc46e2a7 100644 --- a/libavformat/flic.c +++ b/libavformat/flic.c @@ -34,6 +34,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/audioconvert.h" #include "avformat.h" +#include "internal.h" #define FLIC_FILE_MAGIC_1 0xAF11 #define FLIC_FILE_MAGIC_2 0xAF12 @@ -167,10 +168,10 @@ static int flic_read_header(AVFormatContext *s, /* Since the header information is incorrect we have to figure out the * framerate using block_align and the fact that the audio is 22050 Hz. * We usually have two cases: 2205 -> 10 fps and 1470 -> 15 fps */ - av_set_pts_info(st, 64, ast->codec->block_align, FLIC_TFTD_SAMPLE_RATE); - av_set_pts_info(ast, 64, 1, FLIC_TFTD_SAMPLE_RATE); + avpriv_set_pts_info(st, 64, ast->codec->block_align, FLIC_TFTD_SAMPLE_RATE); + avpriv_set_pts_info(ast, 64, 1, FLIC_TFTD_SAMPLE_RATE); } else if (AV_RL16(&header[0x10]) == FLIC_CHUNK_MAGIC_1) { - av_set_pts_info(st, 64, FLIC_MC_SPEED, 70); + avpriv_set_pts_info(st, 64, FLIC_MC_SPEED, 70); /* rewind the stream since the first chunk is at offset 12 */ avio_seek(pb, 12, SEEK_SET); @@ -182,10 +183,10 @@ static int flic_read_header(AVFormatContext *s, memcpy(st->codec->extradata, header, 12); } else if (magic_number == FLIC_FILE_MAGIC_1) { - av_set_pts_info(st, 64, speed, 70); + avpriv_set_pts_info(st, 64, speed, 70); } else if ((magic_number == FLIC_FILE_MAGIC_2) || (magic_number == FLIC_FILE_MAGIC_3)) { - av_set_pts_info(st, 64, speed, 1000); + avpriv_set_pts_info(st, 64, speed, 1000); } else { av_log(s, AV_LOG_INFO, "Invalid or unsupported magic chunk in file\n"); return AVERROR_INVALIDDATA; diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 1459850f4a..5d19dd8413 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -31,6 +31,7 @@ #include "libavcodec/bytestream.h" #include "libavcodec/mpeg4audio.h" #include "avformat.h" +#include "internal.h" #include "avio_internal.h" #include "flv.h" @@ -360,7 +361,7 @@ static AVStream *create_stream(AVFormatContext *s, int is_audio){ return NULL; st->id = is_audio; st->codec->codec_type = is_audio ? AVMEDIA_TYPE_AUDIO : AVMEDIA_TYPE_VIDEO; - av_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */ + avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */ return st; } diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 80ddcd8989..d349ffdd70 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -199,7 +199,7 @@ static int flv_write_header(AVFormatContext *s) if(get_audio_flags(enc)<0) return -1; } - av_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */ + avpriv_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */ sc = av_mallocz(sizeof(FLVStreamContext)); if (!sc) diff --git a/libavformat/gsmdec.c b/libavformat/gsmdec.c index 8c73c7b447..23608873c1 100644 --- a/libavformat/gsmdec.c +++ b/libavformat/gsmdec.c @@ -22,6 +22,7 @@ #include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "avformat.h" +#include "internal.h" #define GSM_BLOCK_SIZE 33 #define GSM_BLOCK_SAMPLES 160 @@ -67,7 +68,7 @@ static int gsm_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->block_align = GSM_BLOCK_SIZE; st->codec->bit_rate = GSM_BLOCK_SIZE * 8 * c->sample_rate / GSM_BLOCK_SAMPLES; - av_set_pts_info(st, 64, GSM_BLOCK_SAMPLES, GSM_SAMPLE_RATE); + avpriv_set_pts_info(st, 64, GSM_BLOCK_SAMPLES, GSM_SAMPLE_RATE); return 0; } diff --git a/libavformat/gxf.c b/libavformat/gxf.c index 473f33a427..ebc4eeafa5 100644 --- a/libavformat/gxf.c +++ b/libavformat/gxf.c @@ -362,7 +362,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { main_timebase = (AVRational){1001, 60000}; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; - av_set_pts_info(st, 32, main_timebase.num, main_timebase.den); + avpriv_set_pts_info(st, 32, main_timebase.num, main_timebase.den); } return 0; } diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 89969b26e1..69650c697b 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -22,6 +22,7 @@ #include "libavutil/intfloat_readwrite.h" #include "libavutil/mathematics.h" #include "avformat.h" +#include "internal.h" #include "gxf.h" #include "riff.h" #include "audiointerleave.h" @@ -676,7 +677,7 @@ static int gxf_write_header(AVFormatContext *s) } sc->track_type = 2; sc->sample_rate = st->codec->sample_rate; - av_set_pts_info(st, 64, 1, sc->sample_rate); + avpriv_set_pts_info(st, 64, 1, sc->sample_rate); sc->sample_size = 16; sc->frame_rate_index = -2; sc->lines_index = -2; @@ -706,7 +707,7 @@ static int gxf_write_header(AVFormatContext *s) "gxf muxer only accepts PAL or NTSC resolutions currently\n"); return -1; } - av_set_pts_info(st, 64, gxf->time_base.num, gxf->time_base.den); + avpriv_set_pts_info(st, 64, gxf->time_base.num, gxf->time_base.den); if (gxf_find_lines_index(st) < 0) sc->lines_index = -1; sc->sample_size = st->codec->bit_rate; diff --git a/libavformat/idcin.c b/libavformat/idcin.c index 64bc5350a3..b26f2aaa8b 100644 --- a/libavformat/idcin.c +++ b/libavformat/idcin.c @@ -70,6 +70,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define HUFFMAN_TABLE_SIZE (64 * 1024) #define IDCIN_FPS 14 @@ -156,7 +157,7 @@ static int idcin_read_header(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 33, 1, IDCIN_FPS); + avpriv_set_pts_info(st, 33, 1, IDCIN_FPS); idcin->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_IDCIN; @@ -177,7 +178,7 @@ static int idcin_read_header(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 33, 1, IDCIN_FPS); + avpriv_set_pts_info(st, 33, 1, IDCIN_FPS); idcin->audio_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_tag = 1; diff --git a/libavformat/idroqdec.c b/libavformat/idroqdec.c index f1c1acca8b..5e347b18ab 100644 --- a/libavformat/idroqdec.c +++ b/libavformat/idroqdec.c @@ -29,6 +29,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define RoQ_MAGIC_NUMBER 0x1084 #define RoQ_CHUNK_PREAMBLE_SIZE 8 @@ -87,7 +88,7 @@ static int roq_read_header(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 63, 1, framerate); + avpriv_set_pts_info(st, 63, 1, framerate); roq->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_ROQ; @@ -169,7 +170,7 @@ static int roq_read_packet(AVFormatContext *s, AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 32, 1, RoQ_AUDIO_SAMPLE_RATE); + avpriv_set_pts_info(st, 32, 1, RoQ_AUDIO_SAMPLE_RATE); roq->audio_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_ROQ_DPCM; diff --git a/libavformat/iff.c b/libavformat/iff.c index e621373862..b895cf2e67 100644 --- a/libavformat/iff.c +++ b/libavformat/iff.c @@ -32,6 +32,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/dict.h" #include "avformat.h" +#include "internal.h" #define ID_8SVX MKTAG('8','S','V','X') #define ID_VHDR MKTAG('V','H','D','R') @@ -216,7 +217,7 @@ static int iff_read_header(AVFormatContext *s, switch(st->codec->codec_type) { case AVMEDIA_TYPE_AUDIO: - av_set_pts_info(st, 32, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate); switch(compression) { case COMP_NONE: diff --git a/libavformat/img2.c b/libavformat/img2.c index 547f23fe0a..898e6a4ca4 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -250,7 +250,7 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap) st->need_parsing = AVSTREAM_PARSE_FULL; } - av_set_pts_info(st, 60, framerate.den, framerate.num); + avpriv_set_pts_info(st, 60, framerate.den, framerate.num); if (width && height) { st->codec->width = width; diff --git a/libavformat/internal.h b/libavformat/internal.h index 0d8bbe7d96..45736687d3 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -286,4 +286,17 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int flags, int64_t *ts_ret, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )); +/** + * Set the pts for a given stream. If the new values would be invalid + * (<= 0), it leaves the AVStream unchanged. + * + * @param s stream + * @param pts_wrap_bits number of bits effectively used by the pts + * (used for wrap control, 33 is the value for MPEG) + * @param pts_num numerator to convert to seconds (MPEG: 1) + * @param pts_den denominator to convert to seconds (MPEG: 90000) + */ +void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, + unsigned int pts_num, unsigned int pts_den); + #endif /* AVFORMAT_INTERNAL_H */ diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index 396742d908..4bd3580bc2 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -34,6 +34,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define CHUNK_PREAMBLE_SIZE 4 #define OPCODE_PREAMBLE_SIZE 4 @@ -562,7 +563,7 @@ static int ipmovie_read_header(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 63, 1, 1000000); + avpriv_set_pts_info(st, 63, 1, 1000000); ipmovie->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_INTERPLAY_VIDEO; @@ -575,7 +576,7 @@ static int ipmovie_read_header(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate); + avpriv_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate); ipmovie->audio_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = ipmovie->audio_type; diff --git a/libavformat/iss.c b/libavformat/iss.c index 845e07ba0c..ec6509c8b0 100644 --- a/libavformat/iss.c +++ b/libavformat/iss.c @@ -27,6 +27,7 @@ */ #include "avformat.h" +#include "internal.h" #include "libavutil/avstring.h" #define ISS_SIG "IMA_ADPCM_Sound" @@ -101,7 +102,7 @@ static av_cold int iss_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * st->codec->bits_per_coded_sample; st->codec->block_align = iss->packet_size; - av_set_pts_info(st, 32, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate); return 0; } diff --git a/libavformat/iv8.c b/libavformat/iv8.c index d036636f6b..78f71e82af 100644 --- a/libavformat/iv8.c +++ b/libavformat/iv8.c @@ -19,6 +19,7 @@ */ #include "avformat.h" +#include "internal.h" static int probe(AVProbeData *p) @@ -47,7 +48,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_MPEG4; st->need_parsing = AVSTREAM_PARSE_FULL; - av_set_pts_info(st, 64, 1, 90000); + avpriv_set_pts_info(st, 64, 1, 90000); return 0; diff --git a/libavformat/ivfdec.c b/libavformat/ivfdec.c index 52a370e652..03f799556d 100644 --- a/libavformat/ivfdec.c +++ b/libavformat/ivfdec.c @@ -19,6 +19,7 @@ */ #include "avformat.h" +#include "internal.h" #include "riff.h" #include "libavutil/intreadwrite.h" @@ -61,7 +62,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) return AVERROR_INVALIDDATA; } - av_set_pts_info(st, 64, time_base.num, time_base.den); + avpriv_set_pts_info(st, 64, time_base.num, time_base.den); return 0; } diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c index 42a4dbf4cc..c24b0c2b1a 100644 --- a/libavformat/jvdec.c +++ b/libavformat/jvdec.c @@ -27,6 +27,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define JV_PREAMBLE_SIZE 5 @@ -81,7 +82,7 @@ static int read_header(AVFormatContext *s, vst->codec->height = avio_rl16(pb); vst->nb_frames = ast->nb_index_entries = avio_rl16(pb); - av_set_pts_info(vst, 64, avio_rl16(pb), 1000); + avpriv_set_pts_info(vst, 64, avio_rl16(pb), 1000); avio_skip(pb, 4); @@ -90,7 +91,7 @@ static int read_header(AVFormatContext *s, ast->codec->codec_tag = 0; /* no fourcc */ ast->codec->sample_rate = avio_rl16(pb); ast->codec->channels = 1; - av_set_pts_info(ast, 64, 1, ast->codec->sample_rate); + avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate); avio_skip(pb, 10); diff --git a/libavformat/libnut.c b/libavformat/libnut.c index fbf9f2ac67..56e8bfc98d 100644 --- a/libavformat/libnut.c +++ b/libavformat/libnut.c @@ -26,6 +26,7 @@ */ #include "avformat.h" +#include "internal.h" #include "riff.h" #include @@ -92,7 +93,7 @@ static int nut_write_header(AVFormatContext * avf) { for (j = 0; j < s[i].fourcc_len; j++) s[i].fourcc[j] = (fourcc >> (j*8)) & 0xFF; ff_parse_specific_params(codec, &num, &ssize, &denom); - av_set_pts_info(avf->streams[i], 60, denom, num); + avpriv_set_pts_info(avf->streams[i], 60, denom, num); s[i].time_base.num = denom; s[i].time_base.den = num; @@ -226,7 +227,7 @@ static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) { memcpy(st->codec->extradata, s[i].codec_specific, st->codec->extradata_size); } - av_set_pts_info(avf->streams[i], 60, s[i].time_base.num, s[i].time_base.den); + avpriv_set_pts_info(avf->streams[i], 60, s[i].time_base.num, s[i].time_base.den); st->start_time = 0; st->duration = s[i].max_pts; diff --git a/libavformat/lmlm4.c b/libavformat/lmlm4.c index db3bf2875f..5f26c4beca 100644 --- a/libavformat/lmlm4.c +++ b/libavformat/lmlm4.c @@ -24,6 +24,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define LMLM4_I_FRAME 0x00 #define LMLM4_P_FRAME 0x01 @@ -65,7 +66,7 @@ static int lmlm4_read_header(AVFormatContext *s, AVFormatParameters *ap) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_MPEG4; st->need_parsing = AVSTREAM_PARSE_HEADERS; - av_set_pts_info(st, 64, 1001, 30000); + avpriv_set_pts_info(st, 64, 1001, 30000); if (!(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c index cfa4f970ad..b3afa7e857 100644 --- a/libavformat/lxfdec.c +++ b/libavformat/lxfdec.c @@ -21,6 +21,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #include "riff.h" #define LXF_PACKET_HEADER_SIZE 60 @@ -174,14 +175,14 @@ static int get_packet_header(AVFormatContext *s, uint8_t *header, uint32_t *form //use audio packet size to determine video standard //for NTSC we have one 8008-sample audio frame per five video frames if (samples == LXF_SAMPLERATE * 5005 / 30000) { - av_set_pts_info(s->streams[0], 64, 1001, 30000); + avpriv_set_pts_info(s->streams[0], 64, 1001, 30000); } else { //assume PAL, but warn if we don't have 1920 samples if (samples != LXF_SAMPLERATE / 25) av_log(s, AV_LOG_WARNING, "video doesn't seem to be PAL or NTSC. guessing PAL\n"); - av_set_pts_info(s->streams[0], 64, 1, 25); + avpriv_set_pts_info(s->streams[0], 64, 1, 25); } //TODO: warning if track mask != (1 << channels) - 1? @@ -250,7 +251,7 @@ static int lxf_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->sample_rate = LXF_SAMPLERATE; st->codec->channels = lxf->channels; - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); } if (format == 1) { diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index b136bbae1c..6fdad8b9fc 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1506,7 +1506,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) if (track->time_scale < 0.01) track->time_scale = 1.0; - av_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000); /* 64 bit pts in ns */ + avpriv_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000); /* 64 bit pts in ns */ st->codec->codec_id = codec_id; st->start_time = 0; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 0667947e09..b8c73bf950 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "internal.h" #include "riff.h" #include "isom.h" #include "matroska.h" @@ -662,7 +663,7 @@ static int mkv_write_tracks(AVFormatContext *s) end_ebml_master(pb, track); // ms precision is the de-facto standard timescale for mkv files - av_set_pts_info(st, 64, 1, 1000); + avpriv_set_pts_info(st, 64, 1, 1000); } end_ebml_master(pb, tracks); return 0; diff --git a/libavformat/mm.c b/libavformat/mm.c index dc4ea71eb3..341cf26a1c 100644 --- a/libavformat/mm.c +++ b/libavformat/mm.c @@ -33,6 +33,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define MM_PREAMBLE_SIZE 6 @@ -113,7 +114,7 @@ static int read_header(AVFormatContext *s, st->codec->codec_tag = 0; /* no fourcc */ st->codec->width = width; st->codec->height = height; - av_set_pts_info(st, 64, 1, frame_rate); + avpriv_set_pts_info(st, 64, 1, frame_rate); /* audio stream */ if (length == MM_HEADER_LEN_AV) { @@ -125,7 +126,7 @@ static int read_header(AVFormatContext *s, st->codec->codec_id = CODEC_ID_PCM_U8; st->codec->channels = 1; st->codec->sample_rate = 8000; - av_set_pts_info(st, 64, 1, 8000); /* 8000 hz */ + avpriv_set_pts_info(st, 64, 1, 8000); /* 8000 hz */ } mm->audio_pts = 0; diff --git a/libavformat/mmf.c b/libavformat/mmf.c index 4028a61545..8e4f2de767 100644 --- a/libavformat/mmf.c +++ b/libavformat/mmf.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avformat.h" +#include "internal.h" #include "avio_internal.h" #include "pcm.h" #include "riff.h" @@ -100,7 +101,7 @@ static int mmf_write_header(AVFormatContext *s) mmf->awapos = ff_start_tag(pb, "Awa\x01"); - av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate); + avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate); avio_flush(pb); @@ -252,7 +253,7 @@ static int mmf_read_header(AVFormatContext *s, st->codec->bits_per_coded_sample = 4; st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_coded_sample; - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); return 0; } diff --git a/libavformat/mov.c b/libavformat/mov.c index c883de39a0..9f45441a71 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -31,6 +31,7 @@ #include "libavutil/avstring.h" #include "libavutil/dict.h" #include "avformat.h" +#include "internal.h" #include "avio_internal.h" #include "riff.h" #include "isom.h" @@ -1827,7 +1828,7 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->time_scale = 1; } - av_set_pts_info(st, 64, 1, sc->time_scale); + avpriv_set_pts_info(st, 64, 1, sc->time_scale); if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !st->codec->frame_size && sc->stts_count == 1) { diff --git a/libavformat/movenc.c b/libavformat/movenc.c index b7314dca41..a741c4b7d0 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2258,7 +2258,7 @@ static int mov_write_header(AVFormatContext *s) if (!track->height) track->height = st->codec->height; - av_set_pts_info(st, 64, 1, track->timescale); + avpriv_set_pts_info(st, 64, 1, track->timescale); } mov_write_mdat_tag(pb, mov); diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 9011f9f996..185d7b8676 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -24,6 +24,7 @@ #include "libavutil/dict.h" #include "libavutil/mathematics.h" #include "avformat.h" +#include "internal.h" #include "id3v2.h" #include "id3v1.h" #include "libavcodec/mpegaudiodecheader.h" @@ -147,7 +148,7 @@ static int mp3_read_header(AVFormatContext *s, st->start_time = 0; // lcm of all mp3 sample rates - av_set_pts_info(st, 64, 1, 14112000); + avpriv_set_pts_info(st, 64, 1, 14112000); off = avio_tell(s->pb); diff --git a/libavformat/mpc.c b/libavformat/mpc.c index a67d9ae218..943121e5fd 100644 --- a/libavformat/mpc.c +++ b/libavformat/mpc.c @@ -21,6 +21,7 @@ #include "libavcodec/get_bits.h" #include "avformat.h" +#include "internal.h" #include "apetag.h" #include "id3v1.h" #include "libavutil/dict.h" @@ -96,7 +97,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE); avio_read(s->pb, st->codec->extradata, 16); st->codec->sample_rate = mpc_rate[st->codec->extradata[2] & 3]; - av_set_pts_info(st, 32, MPC_FRAMESIZE, st->codec->sample_rate); + avpriv_set_pts_info(st, 32, MPC_FRAMESIZE, st->codec->sample_rate); /* scan for seekpoints */ st->start_time = 0; st->duration = c->fcount; diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c index cd89f1c2f2..d9560496f7 100644 --- a/libavformat/mpc8.c +++ b/libavformat/mpc8.c @@ -22,6 +22,7 @@ #include "libavcodec/get_bits.h" #include "libavcodec/unary.h" #include "avformat.h" +#include "internal.h" #include "avio_internal.h" /// Two-byte MPC tag @@ -235,7 +236,7 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->channels = (st->codec->extradata[1] >> 4) + 1; st->codec->sample_rate = mpc8_rate[st->codec->extradata[0] >> 5]; - av_set_pts_info(st, 32, 1152 << (st->codec->extradata[1]&3)*2, st->codec->sample_rate); + avpriv_set_pts_info(st, 32, 1152 << (st->codec->extradata[1]&3)*2, st->codec->sample_rate); st->duration = c->samples / (1152 << (st->codec->extradata[1]&3)*2); size -= avio_tell(pb) - pos; diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index f824d6cb05..d537af61cd 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -25,6 +25,7 @@ #include "libavutil/opt.h" #include "libavcodec/put_bits.h" #include "avformat.h" +#include "internal.h" #include "mpeg.h" #define MAX_PAYLOAD_SIZE 4096 @@ -336,7 +337,7 @@ static int mpeg_mux_init(AVFormatContext *ctx) goto fail; st->priv_data = stream; - av_set_pts_info(st, 64, 1, 90000); + avpriv_set_pts_info(st, 64, 1, 90000); switch(st->codec->codec_type) { case AVMEDIA_TYPE_AUDIO: diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 71447fa507..f7045cee5e 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -577,7 +577,7 @@ static void mpegts_find_stream_type(AVStream *st, static int mpegts_set_stream_info(AVStream *st, PESContext *pes, uint32_t stream_type, uint32_t prog_reg_desc) { - av_set_pts_info(st, 33, 1, 90000); + avpriv_set_pts_info(st, 33, 1, 90000); st->priv_data = pes; st->codec->codec_type = AVMEDIA_TYPE_DATA; st->codec->codec_id = CODEC_ID_NONE; @@ -612,7 +612,7 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, } sub_st->id = pes->pid; - av_set_pts_info(sub_st, 33, 1, 90000); + avpriv_set_pts_info(sub_st, 33, 1, 90000); sub_st->priv_data = sub_pes; sub_st->codec->codec_type = AVMEDIA_TYPE_AUDIO; sub_st->codec->codec_id = CODEC_ID_AC3; @@ -732,7 +732,7 @@ static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf if (cts != AV_NOPTS_VALUE) pes->pts = cts; - av_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res); + avpriv_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res); return (get_bits_count(&gb) + 7) >> 3; } @@ -1920,7 +1920,7 @@ static int mpegts_read_header(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) goto fail; - av_set_pts_info(st, 60, 1, 27000000); + avpriv_set_pts_info(st, 60, 1, 27000000); st->codec->codec_type = AVMEDIA_TYPE_DATA; st->codec->codec_id = CODEC_ID_MPEG2TS; diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index f28b719a29..c36c672053 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -484,7 +484,7 @@ static int mpegts_write_header(AVFormatContext *s) /* assign pids to each stream */ for(i = 0;i < s->nb_streams; i++) { st = s->streams[i]; - av_set_pts_info(st, 33, 1, 90000); + avpriv_set_pts_info(st, 33, 1, 90000); ts_st = av_mallocz(sizeof(MpegTSWriteStream)); if (!ts_st) goto fail; diff --git a/libavformat/msnwc_tcp.c b/libavformat/msnwc_tcp.c index 0c12ea60ef..7e76c07ca6 100644 --- a/libavformat/msnwc_tcp.c +++ b/libavformat/msnwc_tcp.c @@ -20,6 +20,7 @@ #include "libavcodec/bytestream.h" #include "avformat.h" +#include "internal.h" #define HEADER_SIZE 24 @@ -84,7 +85,7 @@ static int msnwc_tcp_read_header(AVFormatContext *ctx, AVFormatParameters *ap) codec->codec_id = CODEC_ID_MIMIC; codec->codec_tag = MKTAG('M', 'L', '2', '0'); - av_set_pts_info(st, 32, 1, 1000); + avpriv_set_pts_info(st, 32, 1, 1000); /* Some files start with "connected\r\n\r\n". * So skip until we find the first byte of struct size */ diff --git a/libavformat/mtv.c b/libavformat/mtv.c index 16e4c90eeb..c3fb15c344 100644 --- a/libavformat/mtv.c +++ b/libavformat/mtv.c @@ -27,6 +27,7 @@ #include "libavutil/bswap.h" #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define MTV_ASUBCHUNK_DATA_SIZE 500 #define MTV_HEADER_SIZE 512 @@ -120,7 +121,7 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap) if(!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 64, 1, mtv->video_fps); + avpriv_set_pts_info(st, 64, 1, mtv->video_fps); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO; st->codec->pix_fmt = PIX_FMT_RGB565; @@ -136,7 +137,7 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap) if(!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 64, 1, AUDIO_SAMPLING_RATE); + avpriv_set_pts_info(st, 64, 1, AUDIO_SAMPLING_RATE); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_MP3; st->codec->bit_rate = mtv->audio_br; diff --git a/libavformat/mvi.c b/libavformat/mvi.c index 60a5bc893b..4782aad479 100644 --- a/libavformat/mvi.c +++ b/libavformat/mvi.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "internal.h" #define MVI_FRAC_BITS 10 @@ -76,14 +77,14 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) return AVERROR_INVALIDDATA; } - av_set_pts_info(ast, 64, 1, ast->codec->sample_rate); + avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_id = CODEC_ID_PCM_U8; ast->codec->channels = 1; ast->codec->bits_per_coded_sample = 8; ast->codec->bit_rate = ast->codec->sample_rate * 8; - av_set_pts_info(vst, 64, msecs_per_frame, 1000000); + avpriv_set_pts_info(vst, 64, msecs_per_frame, 1000000); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = CODEC_ID_MOTIONPIXELS; diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 95699a614e..2a455d7d51 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -758,7 +758,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) if (st->duration == -1) st->duration = AV_NOPTS_VALUE; st->start_time = component->start_position; - av_set_pts_info(st, 64, material_track->edit_rate.num, material_track->edit_rate.den); + avpriv_set_pts_info(st, 64, material_track->edit_rate.num, material_track->edit_rate.den); if (!(source_track->sequence = mxf_resolve_strong_ref(mxf, &source_track->sequence_ref, Sequence))) { av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track sequence strong ref\n"); diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index d375e3fe0e..a7eb432759 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1438,7 +1438,7 @@ static int mxf_write_header(AVFormatContext *s) av_log(s, AV_LOG_ERROR, "unsupported video frame rate\n"); return -1; } - av_set_pts_info(st, 64, mxf->time_base.num, mxf->time_base.den); + avpriv_set_pts_info(st, 64, mxf->time_base.num, mxf->time_base.den); if (s->oformat == &ff_mxf_d10_muxer) { if (st->codec->bit_rate == 50000000) if (mxf->time_base.den == 25) sc->index = 3; @@ -1466,7 +1466,7 @@ static int mxf_write_header(AVFormatContext *s) av_log(s, AV_LOG_ERROR, "only 48khz is implemented\n"); return -1; } - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); if (s->oformat == &ff_mxf_d10_muxer) { if (st->index != 1) { av_log(s, AV_LOG_ERROR, "MXF D-10 only support one audio track\n"); diff --git a/libavformat/mxg.c b/libavformat/mxg.c index 2b69f7204f..a74036436f 100644 --- a/libavformat/mxg.c +++ b/libavformat/mxg.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "libavcodec/mjpeg.h" #include "avformat.h" +#include "internal.h" #include "avio.h" #define DEFAULT_PACKET_SIZE 1024 @@ -47,7 +48,7 @@ static int mxg_read_header(AVFormatContext *s, AVFormatParameters *ap) return AVERROR(ENOMEM); video_st->codec->codec_type = AVMEDIA_TYPE_VIDEO; video_st->codec->codec_id = CODEC_ID_MXPEG; - av_set_pts_info(video_st, 64, 1, 1000000); + avpriv_set_pts_info(video_st, 64, 1, 1000000); audio_st = avformat_new_stream(s, NULL); if (!audio_st) @@ -58,7 +59,7 @@ static int mxg_read_header(AVFormatContext *s, AVFormatParameters *ap) audio_st->codec->sample_rate = 8000; audio_st->codec->bits_per_coded_sample = 8; audio_st->codec->block_align = 1; - av_set_pts_info(audio_st, 64, 1, 1000000); + avpriv_set_pts_info(audio_st, 64, 1, 1000000); mxg->soi_ptr = mxg->buffer_ptr = mxg->buffer = 0; mxg->buffer_size = 0; diff --git a/libavformat/ncdec.c b/libavformat/ncdec.c index 5c2506e5c7..ab1d302a82 100644 --- a/libavformat/ncdec.c +++ b/libavformat/ncdec.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define NC_VIDEO_FLAG 0x1A5 @@ -54,7 +55,7 @@ static int nc_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->codec_id = CODEC_ID_MPEG4; st->need_parsing = AVSTREAM_PARSE_FULL; - av_set_pts_info(st, 64, 1, 100); + avpriv_set_pts_info(st, 64, 1, 100); return 0; } diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index d0fac9afb0..18dfde2867 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -21,6 +21,7 @@ #include "libavutil/mathematics.h" #include "avformat.h" +#include "internal.h" #include "riff.h" #include "libavutil/dict.h" @@ -457,7 +458,7 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->height = vheight; st->codec->bits_per_coded_sample = 24; /* depth XXX */ - av_set_pts_info(st, 64, framerate.den, framerate.num); + avpriv_set_pts_info(st, 64, framerate.den, framerate.num); st->start_time = 0; st->duration = av_rescale(nsv->duration, framerate.num, 1000*framerate.den); @@ -489,7 +490,7 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap) st->need_parsing = AVSTREAM_PARSE_FULL; /* for PCM we will read a chunk later and put correct info */ /* set timebase to common denominator of ms and framerate */ - av_set_pts_info(st, 64, 1, framerate.num*1000); + avpriv_set_pts_info(st, 64, 1, framerate.num*1000); st->start_time = 0; st->duration = (int64_t)nsv->duration * framerate.num; #endif diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index c41b4ce466..9cec89e622 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -374,7 +374,7 @@ static int decode_stream_header(NUTContext *nut){ return -1; } stc->time_base= &nut->time_base[stc->time_base_id]; - av_set_pts_info(s->streams[stream_id], 63, stc->time_base->num, stc->time_base->den); + avpriv_set_pts_info(s->streams[stream_id], 63, stc->time_base->num, stc->time_base->den); return 0; } diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index bde6ba26a8..ae1c2f194c 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -603,7 +603,7 @@ static int nut_write_header(AVFormatContext *s){ AVRational time_base; ff_parse_specific_params(st->codec, &time_base.den, &ssize, &time_base.num); - av_set_pts_info(st, 64, time_base.num, time_base.den); + avpriv_set_pts_info(st, 64, time_base.num, time_base.den); for(j=0; jtime_base_count; j++){ if(!memcmp(&time_base, &nut->time_base[j], sizeof(AVRational))){ diff --git a/libavformat/nuv.c b/libavformat/nuv.c index f9ab6b7045..eede7580ac 100644 --- a/libavformat/nuv.c +++ b/libavformat/nuv.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/intfloat_readwrite.h" #include "avformat.h" +#include "internal.h" #include "riff.h" typedef struct { @@ -163,7 +164,7 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) { vst->codec->bits_per_coded_sample = 10; vst->sample_aspect_ratio = av_d2q(aspect * height / width, 10000); vst->r_frame_rate = av_d2q(fps, 60000); - av_set_pts_info(vst, 32, 1, 1000); + avpriv_set_pts_info(vst, 32, 1, 1000); } else ctx->v_id = -1; @@ -179,7 +180,7 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) { ast->codec->bit_rate = 2 * 2 * 44100 * 8; ast->codec->block_align = 2 * 2; ast->codec->bits_per_coded_sample = 16; - av_set_pts_info(ast, 32, 1, 1000); + avpriv_set_pts_info(ast, 32, 1, 1000); } else ctx->a_id = -1; diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index f7513cffd2..c22f2bed60 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -178,7 +178,7 @@ static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream) return AVERROR(ENOMEM); st->id = idx; - av_set_pts_info(st, 64, 1, 1000000); + avpriv_set_pts_info(st, 64, 1, 1000000); } return idx; diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index 16a14d2708..33aba87039 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -323,9 +323,9 @@ static int ogg_write_header(AVFormatContext *s) unsigned serial_num = i; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) - av_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den); + avpriv_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den); if (st->codec->codec_id != CODEC_ID_VORBIS && st->codec->codec_id != CODEC_ID_THEORA && st->codec->codec_id != CODEC_ID_SPEEX && diff --git a/libavformat/oggparsecelt.c b/libavformat/oggparsecelt.c index 6a0c308e41..5f07de40cb 100644 --- a/libavformat/oggparsecelt.c +++ b/libavformat/oggparsecelt.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #include "oggdec.h" struct oggcelt_private { @@ -71,7 +72,7 @@ static int celt_header(AVFormatContext *s, int idx) st->codec->extradata = extradata; st->codec->extradata_size = 2 * sizeof(uint32_t); if (sample_rate) - av_set_pts_info(st, 64, 1, sample_rate); + avpriv_set_pts_info(st, 64, 1, sample_rate); priv->extra_headers_left = 1 + extra_headers; os->private = priv; AV_WL32(extradata + 0, overlap); diff --git a/libavformat/oggparsedirac.c b/libavformat/oggparsedirac.c index 9991d5692c..8d3a802223 100644 --- a/libavformat/oggparsedirac.c +++ b/libavformat/oggparsedirac.c @@ -21,6 +21,7 @@ #include "libavcodec/get_bits.h" #include "libavcodec/dirac.h" #include "avformat.h" +#include "internal.h" #include "oggdec.h" static int dirac_header(AVFormatContext *s, int idx) @@ -42,7 +43,7 @@ static int dirac_header(AVFormatContext *s, int idx) st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_DIRAC; // dirac in ogg always stores timestamps as though the video were interlaced - av_set_pts_info(st, 64, st->codec->time_base.num, 2*st->codec->time_base.den); + avpriv_set_pts_info(st, 64, st->codec->time_base.num, 2*st->codec->time_base.den); return 1; } @@ -79,7 +80,7 @@ static int old_dirac_header(AVFormatContext *s, int idx) st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_DIRAC; - av_set_pts_info(st, 64, AV_RB32(buf+12), AV_RB32(buf+8)); + avpriv_set_pts_info(st, 64, AV_RB32(buf+12), AV_RB32(buf+8)); return 1; } diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c index e5f517fbdb..b1d18ed12d 100644 --- a/libavformat/oggparseflac.c +++ b/libavformat/oggparseflac.c @@ -22,6 +22,7 @@ #include "libavcodec/get_bits.h" #include "libavcodec/flac.h" #include "avformat.h" +#include "internal.h" #include "oggdec.h" #define OGG_FLAC_METADATA_TYPE_STREAMINFO 0x7F @@ -65,7 +66,7 @@ flac_header (AVFormatContext * s, int idx) memcpy(st->codec->extradata, streaminfo_start, FLAC_STREAMINFO_SIZE); st->codec->extradata_size = FLAC_STREAMINFO_SIZE; - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); } else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) { ff_vorbis_comment (s, &st->metadata, os->buf + os->pstart + 4, os->psize - 4); } diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c index 9526c3acc1..0a8a7c6bd4 100644 --- a/libavformat/oggparseogm.c +++ b/libavformat/oggparseogm.c @@ -27,6 +27,7 @@ #include "libavcodec/get_bits.h" #include "libavcodec/bytestream.h" #include "avformat.h" +#include "internal.h" #include "oggdec.h" #include "riff.h" @@ -81,13 +82,13 @@ ogm_header(AVFormatContext *s, int idx) st->codec->height = bytestream_get_le32(&p); st->codec->time_base.den = spu * 10000000; st->codec->time_base.num = time_unit; - av_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den); + avpriv_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den); } else { st->codec->channels = bytestream_get_le16(&p); p += 2; /* block_align */ st->codec->bit_rate = bytestream_get_le32(&p) * 8; st->codec->sample_rate = spu * 10000000 / time_unit; - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); } } else if (*p == 3) { if (os->psize > 8) diff --git a/libavformat/oggparseskeleton.c b/libavformat/oggparseskeleton.c index ceb7c6991e..62dd14ded1 100644 --- a/libavformat/oggparseskeleton.c +++ b/libavformat/oggparseskeleton.c @@ -20,6 +20,7 @@ #include "libavcodec/bytestream.h" #include "avformat.h" +#include "internal.h" #include "oggdec.h" static int skeleton_header(AVFormatContext *s, int idx) @@ -62,7 +63,7 @@ static int skeleton_header(AVFormatContext *s, int idx) if (start_den) { int base_den; av_reduce(&start_time, &base_den, start_num, start_den, INT_MAX); - av_set_pts_info(st, 64, 1, base_den); + avpriv_set_pts_info(st, 64, 1, base_den); os->lastpts = st->start_time = start_time; } diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c index bbeeb20d60..435ed0cedf 100644 --- a/libavformat/oggparsespeex.c +++ b/libavformat/oggparsespeex.c @@ -28,6 +28,7 @@ #include "libavcodec/get_bits.h" #include "libavcodec/bytestream.h" #include "avformat.h" +#include "internal.h" #include "oggdec.h" struct speex_params { @@ -69,7 +70,7 @@ static int speex_header(AVFormatContext *s, int idx) { + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(st->codec->extradata, p, st->codec->extradata_size); - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); } else ff_vorbis_comment(s, &st->metadata, p, os->psize); diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c index d02781f2fa..993db3ee55 100644 --- a/libavformat/oggparsetheora.c +++ b/libavformat/oggparsetheora.c @@ -26,6 +26,7 @@ #include "libavutil/bswap.h" #include "libavcodec/get_bits.h" #include "avformat.h" +#include "internal.h" #include "oggdec.h" struct theora_params { @@ -91,7 +92,7 @@ theora_header (AVFormatContext * s, int idx) st->codec->time_base.num = 1; st->codec->time_base.den = 25; } - av_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den); + avpriv_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den); st->sample_aspect_ratio.num = get_bits_long(&gb, 24); st->sample_aspect_ratio.den = get_bits_long(&gb, 24); diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index 8a406976b5..ba9b348456 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -254,7 +254,7 @@ vorbis_header (AVFormatContext * s, int idx) if (srate > 0) { st->codec->sample_rate = srate; - av_set_pts_info(st, 64, 1, srate); + avpriv_set_pts_info(st, 64, 1, srate); } } else if (os->buf[os->pstart] == 3) { if (os->psize > 8 && diff --git a/libavformat/oma.c b/libavformat/oma.c index da014689d0..9e98202e4f 100644 --- a/libavformat/oma.c +++ b/libavformat/oma.c @@ -41,6 +41,7 @@ */ #include "avformat.h" +#include "internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/des.h" #include "pcm.h" @@ -343,14 +344,14 @@ static int oma_read_header(AVFormatContext *s, AV_WL16(&edata[10], 1); // always 1 // AV_WL16(&edata[12], 0); // always 0 - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); break; case OMA_CODECID_ATRAC3P: st->codec->channels = (codec_params >> 10) & 7; framesize = ((codec_params & 0x3FF) * 8) + 8; st->codec->sample_rate = srate_tab[(codec_params >> 13) & 7]*100; st->codec->bit_rate = st->codec->sample_rate * framesize * 8 / 1024; - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); av_log(s, AV_LOG_ERROR, "Unsupported codec ATRAC3+!\n"); break; case OMA_CODECID_MP3: diff --git a/libavformat/psxstr.c b/libavformat/psxstr.c index 90385df0cb..d22de0887f 100644 --- a/libavformat/psxstr.c +++ b/libavformat/psxstr.c @@ -31,6 +31,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define RIFF_TAG MKTAG('R', 'I', 'F', 'F') #define CDXA_TAG MKTAG('C', 'D', 'X', 'A') @@ -165,7 +166,7 @@ static int str_read_packet(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 64, 1, 15); + avpriv_set_pts_info(st, 64, 1, 15); str->channels[channel].video_stream_index = st->index; @@ -224,7 +225,7 @@ static int str_read_packet(AVFormatContext *s, // st->codec->bit_rate = 0; //FIXME; st->codec->block_align = 128; - av_set_pts_info(st, 64, 128, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 128, st->codec->sample_rate); } pkt = ret_pkt; if (av_new_packet(pkt, 2304)) diff --git a/libavformat/pva.c b/libavformat/pva.c index 55883d7e9d..263fb5fdc1 100644 --- a/libavformat/pva.c +++ b/libavformat/pva.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "internal.h" #include "mpeg.h" #define PVA_MAX_PAYLOAD_LENGTH 0x17f8 @@ -48,7 +49,7 @@ static int pva_read_header(AVFormatContext *s, AVFormatParameters *ap) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_MPEG2VIDEO; st->need_parsing = AVSTREAM_PARSE_FULL; - av_set_pts_info(st, 32, 1, 90000); + avpriv_set_pts_info(st, 32, 1, 90000); av_add_index_entry(st, 0, 0, 0, 0, AVINDEX_KEYFRAME); if (!(st = avformat_new_stream(s, NULL))) @@ -56,7 +57,7 @@ static int pva_read_header(AVFormatContext *s, AVFormatParameters *ap) { st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_MP2; st->need_parsing = AVSTREAM_PARSE_FULL; - av_set_pts_info(st, 33, 1, 90000); + avpriv_set_pts_info(st, 33, 1, 90000); av_add_index_entry(st, 0, 0, 0, 0, AVINDEX_KEYFRAME); /* the parameters will be extracted from the compressed bitstream */ diff --git a/libavformat/r3d.c b/libavformat/r3d.c index 11d450544a..73e73986ff 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -25,6 +25,7 @@ #include "libavutil/dict.h" #include "libavutil/mathematics.h" #include "avformat.h" +#include "internal.h" typedef struct { unsigned video_offsets_count; @@ -70,7 +71,7 @@ static int r3d_read_red1(AVFormatContext *s) av_dlog(s, "unknown1 %d\n", tmp); tmp = avio_rb32(s->pb); - av_set_pts_info(st, 32, 1, tmp); + avpriv_set_pts_info(st, 32, 1, tmp); tmp = avio_rb32(s->pb); // filenum av_dlog(s, "filenum %d\n", tmp); @@ -95,7 +96,7 @@ static int r3d_read_red1(AVFormatContext *s) ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_id = CODEC_ID_PCM_S32BE; ast->codec->channels = tmp; - av_set_pts_info(ast, 32, 1, st->time_base.den); + avpriv_set_pts_info(ast, 32, 1, st->time_base.den); } avio_read(s->pb, filename, 257); diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index db8a0cd62b..81dd8b49e5 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -21,6 +21,7 @@ */ #include "avformat.h" +#include "internal.h" #include "avio_internal.h" #include "rawdec.h" #include "libavutil/opt.h" @@ -62,7 +63,7 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) 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); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); break; } case AVMEDIA_TYPE_VIDEO: { @@ -84,7 +85,7 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s1->framerate); goto fail; } - av_set_pts_info(st, 64, framerate.den, framerate.num); + avpriv_set_pts_info(st, 64, framerate.den, framerate.num); st->codec->width = width; st->codec->height = height; st->codec->pix_fmt = pix_fmt; @@ -159,7 +160,7 @@ int ff_raw_video_read_header(AVFormatContext *s, } st->codec->time_base = (AVRational){framerate.den, framerate.num}; - av_set_pts_info(st, 64, 1, 1200000); + avpriv_set_pts_info(st, 64, 1, 1200000); fail: return ret; diff --git a/libavformat/rl2.c b/libavformat/rl2.c index e7b9fd9f98..b2be7c0ca9 100644 --- a/libavformat/rl2.c +++ b/libavformat/rl2.c @@ -35,6 +35,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" #include "avformat.h" +#include "internal.h" #define EXTRADATA1_SIZE (6 + 256 * 3) ///< video base, clr, palette @@ -153,10 +154,10 @@ static av_cold int rl2_read_header(AVFormatContext *s, st->codec->bits_per_coded_sample; st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample / 8; - av_set_pts_info(st,32,1,rate); + avpriv_set_pts_info(st,32,1,rate); } - av_set_pts_info(s->streams[0], 32, pts_num, pts_den); + avpriv_set_pts_info(s->streams[0], 32, pts_num, pts_den); chunk_size = av_malloc(frame_count * sizeof(uint32_t)); audio_size = av_malloc(frame_count * sizeof(uint32_t)); diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index a13f970fc6..66b6f8a876 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/dict.h" #include "avformat.h" +#include "internal.h" #include "riff.h" #include "rm.h" @@ -301,7 +302,7 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb, int64_t codec_pos; int ret; - av_set_pts_info(st, 64, 1, 1000); + avpriv_set_pts_info(st, 64, 1, 1000); codec_pos = avio_tell(pb); v = avio_rb32(pb); if (v == MKTAG(0xfd, 'a', 'r', '.')) { diff --git a/libavformat/rpl.c b/libavformat/rpl.c index b2651f1860..0fa00f3f52 100644 --- a/libavformat/rpl.c +++ b/libavformat/rpl.c @@ -22,6 +22,7 @@ #include "libavutil/avstring.h" #include "libavutil/dict.h" #include "avformat.h" +#include "internal.h" #include #define RPL_SIGNATURE "ARMovie\x0A" @@ -149,7 +150,7 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap) vst->codec->bits_per_coded_sample = read_line_and_int(pb, &error); // video bits per sample error |= read_line(pb, line, sizeof(line)); // video frames per second fps = read_fps(line, &error); - av_set_pts_info(vst, 32, fps.den, fps.num); + avpriv_set_pts_info(vst, 32, fps.den, fps.num); // Figure out the video codec switch (vst->codec->codec_tag) { @@ -226,7 +227,7 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap) "RPL audio format %i not supported yet!\n", audio_format); } - av_set_pts_info(ast, 32, 1, ast->codec->bit_rate); + avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate); } else { for (i = 0; i < 3; i++) error |= read_line(pb, line, sizeof(line)); diff --git a/libavformat/rsodec.c b/libavformat/rsodec.c index cdce7e6743..54a3faa076 100644 --- a/libavformat/rsodec.c +++ b/libavformat/rsodec.c @@ -65,7 +65,7 @@ static int rso_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->channels = 1; st->codec->sample_rate = rate; - av_set_pts_info(st, 64, 1, rate); + avpriv_set_pts_info(st, 64, 1, rate); return 0; } diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index 9d8c87b889..6a8472844c 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -33,6 +33,7 @@ #include "rtsp.h" #include "asf.h" #include "avio_internal.h" +#include "internal.h" /** * From MSDN 2.2.1.4, we learn that ASF data packets over RTP should not @@ -141,7 +142,7 @@ static int asfrtp_parse_sdp_line(AVFormatContext *s, int stream_index, *rt->asf_ctx->streams[i]->codec; rt->asf_ctx->streams[i]->codec->extradata_size = 0; rt->asf_ctx->streams[i]->codec->extradata = NULL; - av_set_pts_info(s->streams[stream_index], 32, 1, 1000); + avpriv_set_pts_info(s->streams[stream_index], 32, 1, 1000); } } } diff --git a/libavformat/rtpdec_qt.c b/libavformat/rtpdec_qt.c index 8dd2968398..10371547d1 100644 --- a/libavformat/rtpdec_qt.c +++ b/libavformat/rtpdec_qt.c @@ -26,6 +26,7 @@ */ #include "avformat.h" +#include "internal.h" #include "avio_internal.h" #include "rtp.h" #include "rtpdec.h" @@ -110,7 +111,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && tag != MKTAG('s','o','u','n'))) return AVERROR_INVALIDDATA; - av_set_pts_info(st, 32, 1, avio_rb32(&pb)); + avpriv_set_pts_info(st, 32, 1, avio_rb32(&pb)); if (pos + data_len > len) return AVERROR_INVALIDDATA; diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index dfd7461d18..77ae6f327a 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -130,7 +130,7 @@ static int rtp_write_header(AVFormatContext *s1) } } - av_set_pts_info(st, 32, 1, 90000); + avpriv_set_pts_info(st, 32, 1, 90000); switch(st->codec->codec_id) { case CODEC_ID_MP2: case CODEC_ID_MP3: @@ -166,7 +166,7 @@ static int rtp_write_header(AVFormatContext *s1) case CODEC_ID_ADPCM_G722: /* Due to a historical error, the clock rate for G722 in RTP is * 8000, even if the sample rate is 16000. See RFC 3551. */ - av_set_pts_info(st, 32, 1, 8000); + avpriv_set_pts_info(st, 32, 1, 8000); break; case CODEC_ID_AMR_NB: case CODEC_ID_AMR_WB: @@ -190,7 +190,7 @@ static int rtp_write_header(AVFormatContext *s1) default: defaultcase: if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { - av_set_pts_info(st, 32, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate); } s->buf_ptr = s->buf; break; diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 1f32050c69..7548a418b2 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -228,7 +228,7 @@ static int sdp_parse_rtpmap(AVFormatContext *s, codec->channels = RTSP_DEFAULT_NB_AUDIO_CHANNELS; if (i > 0) { codec->sample_rate = i; - av_set_pts_info(st, 32, 1, codec->sample_rate); + avpriv_set_pts_info(st, 32, 1, codec->sample_rate); get_word_sep(buf, sizeof(buf), "/", &p); i = atoi(buf); if (i > 0) @@ -246,7 +246,7 @@ static int sdp_parse_rtpmap(AVFormatContext *s, case AVMEDIA_TYPE_VIDEO: av_log(s, AV_LOG_DEBUG, "video codec set to: %s\n", c_name); if (i > 0) - av_set_pts_info(st, 32, 1, i); + avpriv_set_pts_info(st, 32, 1, i); break; default: break; @@ -385,7 +385,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, ff_rtp_get_codec_info(st->codec, rtsp_st->sdp_payload_type); if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate > 0) - av_set_pts_info(st, 32, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate); /* Even static payload types may need a custom depacketizer */ handler = ff_rtp_handler_find_by_id( rtsp_st->sdp_payload_type, st->codec->codec_type); diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c index 9bf81d30d4..5c346a75bb 100644 --- a/libavformat/segafilm.c +++ b/libavformat/segafilm.c @@ -29,6 +29,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define FILM_TAG MKBETAG('F', 'I', 'L', 'M') #define FDSC_TAG MKBETAG('F', 'D', 'S', 'C') @@ -197,7 +198,7 @@ static int film_read_header(AVFormatContext *s, return AVERROR(ENOMEM); for(i=0; inb_streams; i++) - av_set_pts_info(s->streams[i], 33, 1, film->base_clock); + avpriv_set_pts_info(s->streams[i], 33, 1, film->base_clock); audio_frame_counter = 0; for (i = 0; i < film->sample_count; i++) { diff --git a/libavformat/sierravmd.c b/libavformat/sierravmd.c index cf66895586..1b5f04b393 100644 --- a/libavformat/sierravmd.c +++ b/libavformat/sierravmd.c @@ -29,6 +29,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define VMD_HEADER_SIZE 0x0330 #define BYTES_PER_FRAME_RECORD 16 @@ -107,7 +108,7 @@ static int vmd_read_header(AVFormatContext *s, vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); - av_set_pts_info(vst, 33, 1, 10); + avpriv_set_pts_info(vst, 33, 1, 10); vmd->video_stream_index = vst->index; vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = vmd->is_indeo3 ? CODEC_ID_INDEO3 : CODEC_ID_VMDVIDEO; @@ -148,8 +149,8 @@ static int vmd_read_header(AVFormatContext *s, num = st->codec->block_align; den = st->codec->sample_rate * st->codec->channels; av_reduce(&den, &num, den, num, (1UL<<31)-1); - av_set_pts_info(vst, 33, num, den); - av_set_pts_info(st, 33, num, den); + avpriv_set_pts_info(vst, 33, num, den); + avpriv_set_pts_info(st, 33, num, den); } toc_offset = AV_RL32(&vmd->vmd_header[812]); diff --git a/libavformat/siff.c b/libavformat/siff.c index 9c24c51f15..9f4d73374c 100644 --- a/libavformat/siff.c +++ b/libavformat/siff.c @@ -21,6 +21,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" enum SIFFTags{ TAG_SIFF = MKTAG('S', 'I', 'F', 'F'), @@ -80,7 +81,7 @@ static int create_audio_stream(AVFormatContext *s, SIFFContext *c) ast->codec->bits_per_coded_sample = c->bits; ast->codec->sample_rate = c->rate; ast->codec->frame_size = c->block_align; - av_set_pts_info(ast, 16, 1, c->rate); + avpriv_set_pts_info(ast, 16, 1, c->rate); return 0; } @@ -124,7 +125,7 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb) st->codec->width = width; st->codec->height = height; st->codec->pix_fmt = PIX_FMT_PAL8; - av_set_pts_info(st, 16, 1, 12); + avpriv_set_pts_info(st, 16, 1, 12); c->cur_frame = 0; c->has_video = 1; diff --git a/libavformat/smacker.c b/libavformat/smacker.c index 279d58626d..770f5364d3 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -26,6 +26,7 @@ #include "libavutil/bswap.h" #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define SMACKER_PAL 0x01 #define SMACKER_FLAG_RING_FRAME 0x01 @@ -171,7 +172,7 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap) smk->pts_inc *= 100; tbase = 100000; av_reduce(&tbase, &smk->pts_inc, tbase, smk->pts_inc, (1UL<<31)-1); - av_set_pts_info(st, 33, smk->pts_inc, tbase); + avpriv_set_pts_info(st, 33, smk->pts_inc, tbase); st->duration = smk->frames; /* handle possible audio streams */ for(i = 0; i < 7; i++) { @@ -195,7 +196,7 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap) ast[i]->codec->bits_per_coded_sample = (smk->aflags[i] & SMK_AUD_16BITS) ? 16 : 8; if(ast[i]->codec->bits_per_coded_sample == 16 && ast[i]->codec->codec_id == CODEC_ID_PCM_U8) ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE; - av_set_pts_info(ast[i], 64, 1, ast[i]->codec->sample_rate + avpriv_set_pts_info(ast[i], 64, 1, ast[i]->codec->sample_rate * ast[i]->codec->channels * ast[i]->codec->bits_per_coded_sample / 8); } } diff --git a/libavformat/sol.c b/libavformat/sol.c index 0fd4259651..31c84ceba0 100644 --- a/libavformat/sol.c +++ b/libavformat/sol.c @@ -25,6 +25,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #include "pcm.h" /* if we don't know the size in advance */ @@ -117,7 +118,7 @@ static int sol_read_header(AVFormatContext *s, st->codec->codec_id = codec; st->codec->channels = channels; st->codec->sample_rate = rate; - av_set_pts_info(st, 64, 1, rate); + avpriv_set_pts_info(st, 64, 1, rate); return 0; } diff --git a/libavformat/soxdec.c b/libavformat/soxdec.c index a9ee817f30..3e426bea00 100644 --- a/libavformat/soxdec.c +++ b/libavformat/soxdec.c @@ -33,6 +33,7 @@ #include "libavutil/intfloat_readwrite.h" #include "libavutil/dict.h" #include "avformat.h" +#include "internal.h" #include "pcm.h" #include "sox.h" @@ -117,7 +118,7 @@ static int sox_read_header(AVFormatContext *s, 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); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); return 0; } diff --git a/libavformat/srtdec.c b/libavformat/srtdec.c index 8927164ff5..ca0a304993 100644 --- a/libavformat/srtdec.c +++ b/libavformat/srtdec.c @@ -45,7 +45,7 @@ static int srt_read_header(AVFormatContext *s, AVFormatParameters *ap) AVStream *st = avformat_new_stream(s, NULL); if (!st) return -1; - av_set_pts_info(st, 64, 1, 1000); + avpriv_set_pts_info(st, 64, 1, 1000); st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codec->codec_id = CODEC_ID_SRT; return 0; diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c index ac3d86c51c..1fc301b696 100644 --- a/libavformat/swfdec.c +++ b/libavformat/swfdec.c @@ -112,7 +112,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) vst->id = ch_id; vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, avio_r8(pb)); - av_set_pts_info(vst, 16, 256, swf->frame_rate); + avpriv_set_pts_info(vst, 16, 256, swf->frame_rate); vst->codec->time_base = (AVRational){ 256, swf->frame_rate }; len -= 8; } else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) { @@ -141,7 +141,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) ast->codec->sample_rate = 5512; else ast->codec->sample_rate = 11025 << (sample_rate_code-1); - av_set_pts_info(ast, 64, 1, ast->codec->sample_rate); + avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate); len -= 4; } else if (tag == TAG_VIDEOFRAME) { int ch_id = avio_rl16(pb); @@ -185,7 +185,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) vst->id = -2; /* -2 to avoid clash with video stream and audio stream */ vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = CODEC_ID_MJPEG; - av_set_pts_info(vst, 64, 256, swf->frame_rate); + avpriv_set_pts_info(vst, 64, 256, swf->frame_rate); vst->codec->time_base = (AVRational){ 256, swf->frame_rate }; st = vst; } diff --git a/libavformat/thp.c b/libavformat/thp.c index 29312b4f78..5b1d180f4b 100644 --- a/libavformat/thp.c +++ b/libavformat/thp.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/intfloat_readwrite.h" #include "avformat.h" +#include "internal.h" typedef struct ThpDemuxContext { int version; @@ -100,7 +101,7 @@ static int thp_read_header(AVFormatContext *s, /* The denominator and numerator are switched because 1/fps is required. */ - av_set_pts_info(st, 64, thp->fps.den, thp->fps.num); + avpriv_set_pts_info(st, 64, thp->fps.den, thp->fps.num); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_THP; st->codec->codec_tag = 0; /* no fourcc */ @@ -127,7 +128,7 @@ static int thp_read_header(AVFormatContext *s, st->codec->channels = avio_rb32(pb); /* numChannels. */ st->codec->sample_rate = avio_rb32(pb); /* Frequency. */ - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); thp->audio_stream_index = st->index; thp->has_audio = 1; diff --git a/libavformat/tiertexseq.c b/libavformat/tiertexseq.c index 03d69db7ac..0590190312 100644 --- a/libavformat/tiertexseq.c +++ b/libavformat/tiertexseq.c @@ -25,6 +25,7 @@ */ #include "avformat.h" +#include "internal.h" #define SEQ_FRAME_SIZE 6144 #define SEQ_FRAME_W 256 @@ -210,7 +211,7 @@ static int seq_read_header(AVFormatContext *s, AVFormatParameters *ap) if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 32, 1, SEQ_FRAME_RATE); + avpriv_set_pts_info(st, 32, 1, SEQ_FRAME_RATE); seq->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_TIERTEXSEQVIDEO; @@ -223,7 +224,7 @@ static int seq_read_header(AVFormatContext *s, AVFormatParameters *ap) if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 32, 1, SEQ_SAMPLE_RATE); + avpriv_set_pts_info(st, 32, 1, SEQ_SAMPLE_RATE); seq->audio_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_PCM_S16BE; diff --git a/libavformat/tmv.c b/libavformat/tmv.c index b0b6a1b224..73b44bbc1d 100644 --- a/libavformat/tmv.c +++ b/libavformat/tmv.c @@ -28,6 +28,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" enum { TMV_PADDING = 0x01, @@ -115,7 +116,7 @@ static int tmv_read_header(AVFormatContext *s, AVFormatParameters *ap) ast->codec->bits_per_coded_sample = 8; ast->codec->bit_rate = ast->codec->sample_rate * ast->codec->bits_per_coded_sample; - av_set_pts_info(ast, 32, 1, ast->codec->sample_rate); + avpriv_set_pts_info(ast, 32, 1, ast->codec->sample_rate); fps.num = ast->codec->sample_rate * ast->codec->channels; fps.den = tmv->audio_chunk_size; @@ -126,7 +127,7 @@ static int tmv_read_header(AVFormatContext *s, AVFormatParameters *ap) vst->codec->pix_fmt = PIX_FMT_PAL8; vst->codec->width = char_cols * 8; vst->codec->height = char_rows * 8; - av_set_pts_info(vst, 32, fps.den, fps.num); + avpriv_set_pts_info(vst, 32, fps.den, fps.num); if (features & TMV_PADDING) tmv->padding = diff --git a/libavformat/tta.c b/libavformat/tta.c index 9efcd1d499..37a359bf70 100644 --- a/libavformat/tta.c +++ b/libavformat/tta.c @@ -21,6 +21,7 @@ #include "libavcodec/get_bits.h" #include "avformat.h" +#include "internal.h" #include "id3v1.h" #include "libavutil/dict.h" @@ -81,7 +82,7 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap) if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 64, 1, samplerate); + avpriv_set_pts_info(st, 64, 1, samplerate); st->start_time = 0; st->duration = datalen; diff --git a/libavformat/tty.c b/libavformat/tty.c index 8f2311dd1c..8041900987 100644 --- a/libavformat/tty.c +++ b/libavformat/tty.c @@ -31,6 +31,7 @@ #include "libavutil/opt.h" #include "libavutil/parseutils.h" #include "avformat.h" +#include "internal.h" #include "sauce.h" typedef struct { @@ -97,7 +98,7 @@ static int read_header(AVFormatContext *avctx, } st->codec->width = width; st->codec->height = height; - av_set_pts_info(st, 60, framerate.den, framerate.num); + avpriv_set_pts_info(st, 60, framerate.den, framerate.num); /* simulate tty display speed */ s->chars_per_frame = FFMAX(av_q2d(st->time_base)*s->chars_per_frame, 1); diff --git a/libavformat/utils.c b/libavformat/utils.c index 29eaf1b15a..10e79eb4da 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2739,7 +2739,7 @@ AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c) st->probe_packets = MAX_PROBE_PACKETS; /* default pts setting is MPEG-like */ - av_set_pts_info(st, 33, 1, 90000); + avpriv_set_pts_info(st, 33, 1, 90000); st->last_IP_pts = AV_NOPTS_VALUE; for(i=0; ipts_buffer[i]= AV_NOPTS_VALUE; @@ -3742,8 +3742,16 @@ int ff_hex_to_data(uint8_t *data, const char *p) return len; } +#if FF_API_SET_PTS_INFO void av_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den) +{ + avpriv_set_pts_info(s, pts_wrap_bits, pts_num, pts_den); +} +#endif + +void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, + unsigned int pts_num, unsigned int pts_den) { AVRational new_tb; if(av_reduce(&new_tb.num, &new_tb.den, pts_num, pts_den, INT_MAX)){ diff --git a/libavformat/vc1test.c b/libavformat/vc1test.c index 172a64c30b..6789b9d283 100644 --- a/libavformat/vc1test.c +++ b/libavformat/vc1test.c @@ -28,6 +28,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define VC1_EXTRADATA_SIZE 4 @@ -71,13 +72,13 @@ static int vc1t_read_header(AVFormatContext *s, avio_skip(pb, 8); fps = avio_rl32(pb); if(fps == 0xFFFFFFFF) - av_set_pts_info(st, 32, 1, 1000); + avpriv_set_pts_info(st, 32, 1, 1000); else{ if (!fps) { av_log(s, AV_LOG_ERROR, "Zero FPS specified, defaulting to 1 FPS\n"); fps = 1; } - av_set_pts_info(st, 24, 1, fps); + avpriv_set_pts_info(st, 24, 1, fps); st->duration = frames; } diff --git a/libavformat/vc1testenc.c b/libavformat/vc1testenc.c index 0ee9b9000b..a1228d8d70 100644 --- a/libavformat/vc1testenc.c +++ b/libavformat/vc1testenc.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avformat.h" +#include "internal.h" typedef struct RCVContext { int frames; @@ -47,7 +48,7 @@ static int vc1test_write_header(AVFormatContext *s) avio_wl32(pb, s->streams[0]->r_frame_rate.den); else avio_wl32(pb, 0xFFFFFFFF); //variable framerate - av_set_pts_info(s->streams[0], 32, 1, 1000); + avpriv_set_pts_info(s->streams[0], 32, 1, 1000); return 0; } diff --git a/libavformat/version.h b/libavformat/version.h index 37c3d5bc88..ba1254f63b 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -113,5 +113,8 @@ #ifndef FF_API_OLD_INTERRUPT_CB #define FF_API_OLD_INTERRUPT_CB (LIBAVFORMAT_VERSION_MAJOR < 54) #endif +#ifndef FF_API_SET_PTS_INFO +#define FF_API_SET_PTS_INFO (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif #endif /* AVFORMAT_VERSION_H */ diff --git a/libavformat/vqf.c b/libavformat/vqf.c index f2c1d8f146..aba763d38f 100644 --- a/libavformat/vqf.c +++ b/libavformat/vqf.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/dict.h" #include "libavutil/mathematics.h" @@ -192,7 +193,7 @@ static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap) return -1; } c->frame_bit_len = st->codec->bit_rate*size/st->codec->sample_rate; - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); /* put first 12 bytes of COMM chunk in extradata */ if (!(st->codec->extradata = av_malloc(12 + FF_INPUT_BUFFER_PADDING_SIZE))) diff --git a/libavformat/wav.c b/libavformat/wav.c index 3e03037a8b..47cb5f8040 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -29,6 +29,7 @@ #include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "avformat.h" +#include "internal.h" #include "avio_internal.h" #include "pcm.h" #include "riff.h" @@ -130,7 +131,7 @@ static int wav_write_header(AVFormatContext *s) if (wav->write_bext) bwf_write_bext_chunk(s); - av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate); + avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate); wav->maxpts = wav->last_duration = 0; wav->minpts = INT64_MAX; @@ -281,7 +282,7 @@ static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st) return ret; (*st)->need_parsing = AVSTREAM_PARSE_FULL; - av_set_pts_info(*st, 64, 1, (*st)->codec->sample_rate); + avpriv_set_pts_info(*st, 64, 1, (*st)->codec->sample_rate); return 0; } @@ -660,7 +661,7 @@ static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap) st->need_parsing = AVSTREAM_PARSE_FULL; - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); size = find_guid(pb, guid_data); if (size < 0) { diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c index b4d277239f..af5470f6f2 100644 --- a/libavformat/wc3movie.c +++ b/libavformat/wc3movie.c @@ -30,6 +30,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/dict.h" #include "avformat.h" +#include "internal.h" #define FORM_TAG MKTAG('F', 'O', 'R', 'M') #define MOVE_TAG MKTAG('M', 'O', 'V', 'E') @@ -166,7 +167,7 @@ static int wc3_read_header(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 33, 1, WC3_FRAME_FPS); + avpriv_set_pts_info(st, 33, 1, WC3_FRAME_FPS); wc3->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_XAN_WC3; @@ -177,7 +178,7 @@ static int wc3_read_header(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 33, 1, WC3_FRAME_FPS); + avpriv_set_pts_info(st, 33, 1, WC3_FRAME_FPS); wc3->audio_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_PCM_S16LE; diff --git a/libavformat/westwood.c b/libavformat/westwood.c index be0140b596..67a00c9c33 100644 --- a/libavformat/westwood.c +++ b/libavformat/westwood.c @@ -35,6 +35,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define AUD_HEADER_SIZE 12 #define AUD_CHUNK_PREAMBLE_SIZE 8 @@ -147,7 +148,7 @@ static int wsaud_read_header(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 33, 1, wsaud->audio_samplerate); + avpriv_set_pts_info(st, 33, 1, wsaud->audio_samplerate); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = wsaud->audio_type; st->codec->codec_tag = 0; /* no tag */ @@ -224,7 +225,7 @@ static int wsvqa_read_header(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 33, 1, VQA_FRAMERATE); + avpriv_set_pts_info(st, 33, 1, VQA_FRAMERATE); wsvqa->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_WS_VQA; @@ -250,7 +251,7 @@ static int wsvqa_read_header(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 33, 1, VQA_FRAMERATE); + avpriv_set_pts_info(st, 33, 1, VQA_FRAMERATE); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; if (AV_RL16(&header[0]) == 1) st->codec->codec_id = CODEC_ID_WESTWOOD_SND1; diff --git a/libavformat/wtv.c b/libavformat/wtv.c index c3bc083201..0cef6fb240 100644 --- a/libavformat/wtv.c +++ b/libavformat/wtv.c @@ -633,7 +633,7 @@ static AVStream * new_stream(AVFormatContext *s, AVStream *st, int sid, int code } st->codec->codec_type = codec_type; st->need_parsing = AVSTREAM_PARSE_FULL; - av_set_pts_info(st, 64, 1, 10000000); + avpriv_set_pts_info(st, 64, 1, 10000000); return st; } diff --git a/libavformat/wv.c b/libavformat/wv.c index 4816ed670e..5f7b3b442a 100644 --- a/libavformat/wv.c +++ b/libavformat/wv.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/dict.h" #include "avformat.h" +#include "internal.h" #include "apetag.h" #include "id3v1.h" @@ -229,7 +230,7 @@ static int wv_read_header(AVFormatContext *s, st->codec->channel_layout = wc->chmask; st->codec->sample_rate = wc->rate; st->codec->bits_per_coded_sample = wc->bpp; - av_set_pts_info(st, 64, 1, wc->rate); + avpriv_set_pts_info(st, 64, 1, wc->rate); st->start_time = 0; st->duration = wc->samples; diff --git a/libavformat/xa.c b/libavformat/xa.c index cdff35de7d..0a1ad59f2c 100644 --- a/libavformat/xa.c +++ b/libavformat/xa.c @@ -29,6 +29,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define XA00_TAG MKTAG('X', 'A', 0, 0) #define XAI0_TAG MKTAG('X', 'A', 'I', 0) @@ -86,7 +87,7 @@ static int xa_read_header(AVFormatContext *s, st->codec->block_align = avio_rl16(pb); st->codec->bits_per_coded_sample = avio_rl16(pb); - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); return 0; } diff --git a/libavformat/xmv.c b/libavformat/xmv.c index 30e3b5ade9..bc4b23917a 100644 --- a/libavformat/xmv.c +++ b/libavformat/xmv.c @@ -30,6 +30,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #include "riff.h" #define XMV_MIN_HEADER_SIZE 36 @@ -154,7 +155,7 @@ static int xmv_read_header(AVFormatContext *s, if (!vst) return AVERROR(ENOMEM); - av_set_pts_info(vst, 32, 1, 1000); + avpriv_set_pts_info(vst, 32, 1, 1000); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = CODEC_ID_WMV2; @@ -224,7 +225,7 @@ static int xmv_read_header(AVFormatContext *s, ast->codec->bit_rate = track->bit_rate; ast->codec->block_align = 36 * track->channels; - av_set_pts_info(ast, 32, track->block_samples, track->sample_rate); + avpriv_set_pts_info(ast, 32, track->block_samples, track->sample_rate); packet->stream_index = ast->index; diff --git a/libavformat/xwma.c b/libavformat/xwma.c index 9a1a6b62b9..5839bdcd22 100644 --- a/libavformat/xwma.c +++ b/libavformat/xwma.c @@ -22,6 +22,7 @@ #include #include "avformat.h" +#include "internal.h" #include "riff.h" /* @@ -115,7 +116,7 @@ static int xwma_read_header(AVFormatContext *s, AVFormatParameters *ap) } /* set the sample rate */ - av_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); /* parse the remaining RIFF chunks */ for (;;) { diff --git a/libavformat/yop.c b/libavformat/yop.c index c9bf9f8c4a..a317825a7c 100644 --- a/libavformat/yop.c +++ b/libavformat/yop.c @@ -24,6 +24,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" typedef struct yop_dec_context { AVPacket video_packet; @@ -105,7 +106,7 @@ static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap) avio_seek(pb, 2048, SEEK_SET); - av_set_pts_info(video_stream, 32, 1, frame_rate); + avpriv_set_pts_info(video_stream, 32, 1, frame_rate); return 0; } diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c index e1db1a377b..66fcc1f2a1 100644 --- a/libavformat/yuv4mpeg.c +++ b/libavformat/yuv4mpeg.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avformat.h" +#include "internal.h" #define Y4M_MAGIC "YUV4MPEG2" #define Y4M_FRAME_MAGIC "FRAME" @@ -333,7 +334,7 @@ static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->width = width; st->codec->height = height; av_reduce(&raten, &rated, raten, rated, (1UL<<31)-1); - av_set_pts_info(st, 64, rated, raten); + avpriv_set_pts_info(st, 64, rated, raten); st->codec->pix_fmt = pix_fmt; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO; From bb8a6e03cc641035b3fd4dc7c8c77f2dc92b41d5 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Wed, 5 Oct 2011 09:29:38 +0200 Subject: [PATCH 10/11] rv40: move loop filter to rv34dsp context Signed-off-by: Mans Rullgard --- libavcodec/rv34dsp.h | 7 ++ libavcodec/rv40.c | 158 +++-------------------------------------- libavcodec/rv40data.h | 14 ---- libavcodec/rv40dsp.c | 161 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 176 insertions(+), 164 deletions(-) diff --git a/libavcodec/rv34dsp.h b/libavcodec/rv34dsp.h index a2ab5f232b..4ade05060f 100644 --- a/libavcodec/rv34dsp.h +++ b/libavcodec/rv34dsp.h @@ -36,6 +36,11 @@ typedef void (*rv40_weight_func)(uint8_t *dst/*align width (8 or 16)*/, typedef void (*rv34_inv_transform_func)(DCTELEM *block); +typedef void (*rv40_loop_filter_func)(uint8_t *src, int stride, int dmode, + int lim_q1, int lim_p1, int alpha, + int beta, int beta2, int chroma, + int edge); + typedef struct RV34DSPContext { qpel_mc_func put_pixels_tab[4][16]; qpel_mc_func avg_pixels_tab[4][16]; @@ -43,6 +48,8 @@ typedef struct RV34DSPContext { h264_chroma_mc_func avg_chroma_pixels_tab[3]; rv40_weight_func rv40_weight_pixels_tab[2]; rv34_inv_transform_func rv34_inv_transform_tab[2]; + rv40_loop_filter_func rv40_h_loop_filter; + rv40_loop_filter_func rv40_v_loop_filter; } RV34DSPContext; void ff_rv30dsp_init(RV34DSPContext *c, DSPContext* dsp); diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 7f6c8dfcb4..3216e838ef 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -271,148 +271,6 @@ static int rv40_decode_mb_info(RV34DecContext *r) return 0; } -#define CLIP_SYMM(a, b) av_clip(a, -(b), b) -/** - * weaker deblocking very similar to the one described in 4.4.2 of JVT-A003r1 - */ -static inline void rv40_weak_loop_filter(uint8_t *src, const int step, - const int filter_p1, const int filter_q1, - const int alpha, const int beta, - const int lim_p0q0, - const int lim_q1, const int lim_p1, - const int diff_p1p0, const int diff_q1q0, - const int diff_p1p2, const int diff_q1q2) -{ - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; - int t, u, diff; - - t = src[0*step] - src[-1*step]; - if(!t) - return; - u = (alpha * FFABS(t)) >> 7; - if(u > 3 - (filter_p1 && filter_q1)) - return; - - t <<= 2; - if(filter_p1 && filter_q1) - t += src[-2*step] - src[1*step]; - diff = CLIP_SYMM((t + 4) >> 3, lim_p0q0); - src[-1*step] = cm[src[-1*step] + diff]; - src[ 0*step] = cm[src[ 0*step] - diff]; - if(FFABS(diff_p1p2) <= beta && filter_p1){ - t = (diff_p1p0 + diff_p1p2 - diff) >> 1; - src[-2*step] = cm[src[-2*step] - CLIP_SYMM(t, lim_p1)]; - } - if(FFABS(diff_q1q2) <= beta && filter_q1){ - t = (diff_q1q0 + diff_q1q2 + diff) >> 1; - src[ 1*step] = cm[src[ 1*step] - CLIP_SYMM(t, lim_q1)]; - } -} - -static av_always_inline void rv40_adaptive_loop_filter(uint8_t *src, const int step, - const int stride, const int dmode, - const int lim_q1, const int lim_p1, - const int alpha, - const int beta, const int beta2, - const int chroma, const int edge) -{ - int diff_p1p0[4], diff_q1q0[4], diff_p1p2[4], diff_q1q2[4]; - int sum_p1p0 = 0, sum_q1q0 = 0, sum_p1p2 = 0, sum_q1q2 = 0; - uint8_t *ptr; - int flag_strong0 = 1, flag_strong1 = 1; - int filter_p1, filter_q1; - int i; - int lims; - - for(i = 0, ptr = src; i < 4; i++, ptr += stride){ - diff_p1p0[i] = ptr[-2*step] - ptr[-1*step]; - diff_q1q0[i] = ptr[ 1*step] - ptr[ 0*step]; - sum_p1p0 += diff_p1p0[i]; - sum_q1q0 += diff_q1q0[i]; - } - filter_p1 = FFABS(sum_p1p0) < (beta<<2); - filter_q1 = FFABS(sum_q1q0) < (beta<<2); - if(!filter_p1 && !filter_q1) - return; - - for(i = 0, ptr = src; i < 4; i++, ptr += stride){ - diff_p1p2[i] = ptr[-2*step] - ptr[-3*step]; - diff_q1q2[i] = ptr[ 1*step] - ptr[ 2*step]; - sum_p1p2 += diff_p1p2[i]; - sum_q1q2 += diff_q1q2[i]; - } - - if(edge){ - flag_strong0 = filter_p1 && (FFABS(sum_p1p2) < beta2); - flag_strong1 = filter_q1 && (FFABS(sum_q1q2) < beta2); - }else{ - flag_strong0 = flag_strong1 = 0; - } - - lims = filter_p1 + filter_q1 + ((lim_q1 + lim_p1) >> 1) + 1; - if(flag_strong0 && flag_strong1){ /* strong filtering */ - for(i = 0; i < 4; i++, src += stride){ - int sflag, p0, q0, p1, q1; - int t = src[0*step] - src[-1*step]; - - if(!t) continue; - sflag = (alpha * FFABS(t)) >> 7; - if(sflag > 1) continue; - - p0 = (25*src[-3*step] + 26*src[-2*step] - + 26*src[-1*step] - + 26*src[ 0*step] + 25*src[ 1*step] + rv40_dither_l[dmode + i]) >> 7; - q0 = (25*src[-2*step] + 26*src[-1*step] - + 26*src[ 0*step] - + 26*src[ 1*step] + 25*src[ 2*step] + rv40_dither_r[dmode + i]) >> 7; - if(sflag){ - p0 = av_clip(p0, src[-1*step] - lims, src[-1*step] + lims); - q0 = av_clip(q0, src[ 0*step] - lims, src[ 0*step] + lims); - } - p1 = (25*src[-4*step] + 26*src[-3*step] - + 26*src[-2*step] - + 26*p0 + 25*src[ 0*step] + rv40_dither_l[dmode + i]) >> 7; - q1 = (25*src[-1*step] + 26*q0 - + 26*src[ 1*step] - + 26*src[ 2*step] + 25*src[ 3*step] + rv40_dither_r[dmode + i]) >> 7; - if(sflag){ - p1 = av_clip(p1, src[-2*step] - lims, src[-2*step] + lims); - q1 = av_clip(q1, src[ 1*step] - lims, src[ 1*step] + lims); - } - src[-2*step] = p1; - src[-1*step] = p0; - src[ 0*step] = q0; - src[ 1*step] = q1; - if(!chroma){ - src[-3*step] = (25*src[-1*step] + 26*src[-2*step] + 51*src[-3*step] + 26*src[-4*step] + 64) >> 7; - src[ 2*step] = (25*src[ 0*step] + 26*src[ 1*step] + 51*src[ 2*step] + 26*src[ 3*step] + 64) >> 7; - } - } - }else if(filter_p1 && filter_q1){ - for(i = 0; i < 4; i++, src += stride) - rv40_weak_loop_filter(src, step, 1, 1, alpha, beta, lims, lim_q1, lim_p1, - diff_p1p0[i], diff_q1q0[i], diff_p1p2[i], diff_q1q2[i]); - }else{ - for(i = 0; i < 4; i++, src += stride) - rv40_weak_loop_filter(src, step, filter_p1, filter_q1, - alpha, beta, lims>>1, lim_q1>>1, lim_p1>>1, - diff_p1p0[i], diff_q1q0[i], diff_p1p2[i], diff_q1q2[i]); - } -} - -static void rv40_v_loop_filter(uint8_t *src, int stride, int dmode, - int lim_q1, int lim_p1, - int alpha, int beta, int beta2, int chroma, int edge){ - rv40_adaptive_loop_filter(src, 1, stride, dmode, lim_q1, lim_p1, - alpha, beta, beta2, chroma, edge); -} -static void rv40_h_loop_filter(uint8_t *src, int stride, int dmode, - int lim_q1, int lim_p1, - int alpha, int beta, int beta2, int chroma, int edge){ - rv40_adaptive_loop_filter(src, stride, 1, dmode, lim_q1, lim_p1, - alpha, beta, beta2, chroma, edge); -} - enum RV40BlockPos{ POS_CUR, POS_TOP, @@ -572,7 +430,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row) // if bottom block is coded then we can filter its top edge // (or bottom edge of this block, which is the same) if(y_h_deblock & (MASK_BOTTOM << ij)){ - rv40_h_loop_filter(Y+4*s->linesize, s->linesize, dither, + r->rdsp.rv40_h_loop_filter(Y+4*s->linesize, s->linesize, dither, y_to_deblock & (MASK_BOTTOM << ij) ? clip[POS_CUR] : 0, clip_cur, alpha, beta, betaY, 0, 0); @@ -583,14 +441,14 @@ static void rv40_loop_filter(RV34DecContext *r, int row) clip_left = mvmasks[POS_LEFT] & (MASK_RIGHT << j) ? clip[POS_LEFT] : 0; else clip_left = y_to_deblock & (MASK_CUR << (ij-1)) ? clip[POS_CUR] : 0; - rv40_v_loop_filter(Y, s->linesize, dither, + r->rdsp.rv40_v_loop_filter(Y, s->linesize, dither, clip_cur, clip_left, alpha, beta, betaY, 0, 0); } // filter top edge of the current macroblock when filtering strength is high if(!j && y_h_deblock & (MASK_CUR << i) && (mb_strong[POS_CUR] || mb_strong[POS_TOP])){ - rv40_h_loop_filter(Y, s->linesize, dither, + r->rdsp.rv40_h_loop_filter(Y, s->linesize, dither, clip_cur, mvmasks[POS_TOP] & (MASK_TOP << i) ? clip[POS_TOP] : 0, alpha, beta, betaY, 0, 1); @@ -598,7 +456,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row) // filter left block edge in edge mode (with high filtering strength) if(y_v_deblock & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] || mb_strong[POS_LEFT])){ clip_left = mvmasks[POS_LEFT] & (MASK_RIGHT << j) ? clip[POS_LEFT] : 0; - rv40_v_loop_filter(Y, s->linesize, dither, + r->rdsp.rv40_v_loop_filter(Y, s->linesize, dither, clip_cur, clip_left, alpha, beta, betaY, 0, 1); @@ -613,7 +471,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row) int clip_cur = c_to_deblock[k] & (MASK_CUR << ij) ? clip[POS_CUR] : 0; if(c_h_deblock[k] & (MASK_CUR << (ij+2))){ int clip_bot = c_to_deblock[k] & (MASK_CUR << (ij+2)) ? clip[POS_CUR] : 0; - rv40_h_loop_filter(C+4*s->uvlinesize, s->uvlinesize, i*8, + r->rdsp.rv40_h_loop_filter(C+4*s->uvlinesize, s->uvlinesize, i*8, clip_bot, clip_cur, alpha, beta, betaC, 1, 0); @@ -623,21 +481,21 @@ static void rv40_loop_filter(RV34DecContext *r, int row) clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0; else clip_left = c_to_deblock[k] & (MASK_CUR << (ij-1)) ? clip[POS_CUR] : 0; - rv40_v_loop_filter(C, s->uvlinesize, j*8, + r->rdsp.rv40_v_loop_filter(C, s->uvlinesize, j*8, clip_cur, clip_left, alpha, beta, betaC, 1, 0); } if(!j && c_h_deblock[k] & (MASK_CUR << ij) && (mb_strong[POS_CUR] || mb_strong[POS_TOP])){ int clip_top = uvcbp[POS_TOP][k] & (MASK_CUR << (ij+2)) ? clip[POS_TOP] : 0; - rv40_h_loop_filter(C, s->uvlinesize, i*8, + r->rdsp.rv40_h_loop_filter(C, s->uvlinesize, i*8, clip_cur, clip_top, alpha, beta, betaC, 1, 1); } if(c_v_deblock[k] & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] || mb_strong[POS_LEFT])){ clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0; - rv40_v_loop_filter(C, s->uvlinesize, j*8, + r->rdsp.rv40_v_loop_filter(C, s->uvlinesize, j*8, clip_cur, clip_left, alpha, beta, betaC, 1, 1); diff --git a/libavcodec/rv40data.h b/libavcodec/rv40data.h index 1b6e8c31b1..42328af5a8 100644 --- a/libavcodec/rv40data.h +++ b/libavcodec/rv40data.h @@ -68,20 +68,6 @@ static const uint8_t rv40_luma_dc_quant[2][32] = { * @name Coefficients used by the RV40 loop filter * @{ */ -/** - * dither values for deblocking filter - left/top values - */ -static const uint8_t rv40_dither_l[16] = { - 0x40, 0x50, 0x20, 0x60, 0x30, 0x50, 0x40, 0x30, - 0x50, 0x40, 0x50, 0x30, 0x60, 0x20, 0x50, 0x40 -}; -/** - * dither values for deblocking filter - right/bottom values - */ -static const uint8_t rv40_dither_r[16] = { - 0x40, 0x30, 0x60, 0x20, 0x50, 0x30, 0x30, 0x40, - 0x40, 0x40, 0x50, 0x30, 0x20, 0x60, 0x30, 0x40 -}; /** alpha parameter for RV40 loop filter - almost the same as in JVT-A003r1 */ static const uint8_t rv40_alpha_tab[32] = { diff --git a/libavcodec/rv40dsp.c b/libavcodec/rv40dsp.c index efc049f1cb..f193b6050d 100644 --- a/libavcodec/rv40dsp.c +++ b/libavcodec/rv40dsp.c @@ -294,6 +294,164 @@ static void rv40_weight_func_ ## size (uint8_t *dst, uint8_t *src1, uint8_t *src RV40_WEIGHT_FUNC(16) RV40_WEIGHT_FUNC(8) +/** + * dither values for deblocking filter - left/top values + */ +static const uint8_t rv40_dither_l[16] = { + 0x40, 0x50, 0x20, 0x60, 0x30, 0x50, 0x40, 0x30, + 0x50, 0x40, 0x50, 0x30, 0x60, 0x20, 0x50, 0x40 +}; + +/** + * dither values for deblocking filter - right/bottom values + */ +static const uint8_t rv40_dither_r[16] = { + 0x40, 0x30, 0x60, 0x20, 0x50, 0x30, 0x30, 0x40, + 0x40, 0x40, 0x50, 0x30, 0x20, 0x60, 0x30, 0x40 +}; + +#define CLIP_SYMM(a, b) av_clip(a, -(b), b) +/** + * weaker deblocking very similar to the one described in 4.4.2 of JVT-A003r1 + */ +static inline void rv40_weak_loop_filter(uint8_t *src, const int step, + const int filter_p1, const int filter_q1, + const int alpha, const int beta, + const int lim_p0q0, + const int lim_q1, const int lim_p1, + const int diff_p1p0, const int diff_q1q0, + const int diff_p1p2, const int diff_q1q2) +{ + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + int t, u, diff; + + t = src[0*step] - src[-1*step]; + if(!t) + return; + u = (alpha * FFABS(t)) >> 7; + if(u > 3 - (filter_p1 && filter_q1)) + return; + + t <<= 2; + if(filter_p1 && filter_q1) + t += src[-2*step] - src[1*step]; + diff = CLIP_SYMM((t + 4) >> 3, lim_p0q0); + src[-1*step] = cm[src[-1*step] + diff]; + src[ 0*step] = cm[src[ 0*step] - diff]; + if(FFABS(diff_p1p2) <= beta && filter_p1){ + t = (diff_p1p0 + diff_p1p2 - diff) >> 1; + src[-2*step] = cm[src[-2*step] - CLIP_SYMM(t, lim_p1)]; + } + if(FFABS(diff_q1q2) <= beta && filter_q1){ + t = (diff_q1q0 + diff_q1q2 + diff) >> 1; + src[ 1*step] = cm[src[ 1*step] - CLIP_SYMM(t, lim_q1)]; + } +} + +static av_always_inline void rv40_adaptive_loop_filter(uint8_t *src, const int step, + const int stride, const int dmode, + const int lim_q1, const int lim_p1, + const int alpha, + const int beta, const int beta2, + const int chroma, const int edge) +{ + int diff_p1p0[4], diff_q1q0[4], diff_p1p2[4], diff_q1q2[4]; + int sum_p1p0 = 0, sum_q1q0 = 0, sum_p1p2 = 0, sum_q1q2 = 0; + uint8_t *ptr; + int flag_strong0 = 1, flag_strong1 = 1; + int filter_p1, filter_q1; + int i; + int lims; + + for(i = 0, ptr = src; i < 4; i++, ptr += stride){ + diff_p1p0[i] = ptr[-2*step] - ptr[-1*step]; + diff_q1q0[i] = ptr[ 1*step] - ptr[ 0*step]; + sum_p1p0 += diff_p1p0[i]; + sum_q1q0 += diff_q1q0[i]; + } + filter_p1 = FFABS(sum_p1p0) < (beta<<2); + filter_q1 = FFABS(sum_q1q0) < (beta<<2); + if(!filter_p1 && !filter_q1) + return; + + for(i = 0, ptr = src; i < 4; i++, ptr += stride){ + diff_p1p2[i] = ptr[-2*step] - ptr[-3*step]; + diff_q1q2[i] = ptr[ 1*step] - ptr[ 2*step]; + sum_p1p2 += diff_p1p2[i]; + sum_q1q2 += diff_q1q2[i]; + } + + if(edge){ + flag_strong0 = filter_p1 && (FFABS(sum_p1p2) < beta2); + flag_strong1 = filter_q1 && (FFABS(sum_q1q2) < beta2); + }else{ + flag_strong0 = flag_strong1 = 0; + } + + lims = filter_p1 + filter_q1 + ((lim_q1 + lim_p1) >> 1) + 1; + if(flag_strong0 && flag_strong1){ /* strong filtering */ + for(i = 0; i < 4; i++, src += stride){ + int sflag, p0, q0, p1, q1; + int t = src[0*step] - src[-1*step]; + + if(!t) continue; + sflag = (alpha * FFABS(t)) >> 7; + if(sflag > 1) continue; + + p0 = (25*src[-3*step] + 26*src[-2*step] + + 26*src[-1*step] + + 26*src[ 0*step] + 25*src[ 1*step] + rv40_dither_l[dmode + i]) >> 7; + q0 = (25*src[-2*step] + 26*src[-1*step] + + 26*src[ 0*step] + + 26*src[ 1*step] + 25*src[ 2*step] + rv40_dither_r[dmode + i]) >> 7; + if(sflag){ + p0 = av_clip(p0, src[-1*step] - lims, src[-1*step] + lims); + q0 = av_clip(q0, src[ 0*step] - lims, src[ 0*step] + lims); + } + p1 = (25*src[-4*step] + 26*src[-3*step] + + 26*src[-2*step] + + 26*p0 + 25*src[ 0*step] + rv40_dither_l[dmode + i]) >> 7; + q1 = (25*src[-1*step] + 26*q0 + + 26*src[ 1*step] + + 26*src[ 2*step] + 25*src[ 3*step] + rv40_dither_r[dmode + i]) >> 7; + if(sflag){ + p1 = av_clip(p1, src[-2*step] - lims, src[-2*step] + lims); + q1 = av_clip(q1, src[ 1*step] - lims, src[ 1*step] + lims); + } + src[-2*step] = p1; + src[-1*step] = p0; + src[ 0*step] = q0; + src[ 1*step] = q1; + if(!chroma){ + src[-3*step] = (25*src[-1*step] + 26*src[-2*step] + 51*src[-3*step] + 26*src[-4*step] + 64) >> 7; + src[ 2*step] = (25*src[ 0*step] + 26*src[ 1*step] + 51*src[ 2*step] + 26*src[ 3*step] + 64) >> 7; + } + } + }else if(filter_p1 && filter_q1){ + for(i = 0; i < 4; i++, src += stride) + rv40_weak_loop_filter(src, step, 1, 1, alpha, beta, lims, lim_q1, lim_p1, + diff_p1p0[i], diff_q1q0[i], diff_p1p2[i], diff_q1q2[i]); + }else{ + for(i = 0; i < 4; i++, src += stride) + rv40_weak_loop_filter(src, step, filter_p1, filter_q1, + alpha, beta, lims>>1, lim_q1>>1, lim_p1>>1, + diff_p1p0[i], diff_q1q0[i], diff_p1p2[i], diff_q1q2[i]); + } +} + +static void rv40_v_loop_filter(uint8_t *src, int stride, int dmode, + int lim_q1, int lim_p1, + int alpha, int beta, int beta2, int chroma, int edge){ + rv40_adaptive_loop_filter(src, 1, stride, dmode, lim_q1, lim_p1, + alpha, beta, beta2, chroma, edge); +} +static void rv40_h_loop_filter(uint8_t *src, int stride, int dmode, + int lim_q1, int lim_p1, + int alpha, int beta, int beta2, int chroma, int edge){ + rv40_adaptive_loop_filter(src, stride, 1, dmode, lim_q1, lim_p1, + alpha, beta, beta2, chroma, edge); +} + av_cold void ff_rv40dsp_init(RV34DSPContext *c, DSPContext* dsp) { ff_rv34dsp_init(c, dsp); @@ -371,6 +529,9 @@ av_cold void ff_rv40dsp_init(RV34DSPContext *c, DSPContext* dsp) { c->rv40_weight_pixels_tab[0] = rv40_weight_func_16; c->rv40_weight_pixels_tab[1] = rv40_weight_func_8; + c->rv40_h_loop_filter = rv40_h_loop_filter; + c->rv40_v_loop_filter = rv40_v_loop_filter; + if (HAVE_MMX) ff_rv40dsp_init_x86(c, dsp); } From c8f0e88b205208da0e74f9345d4c4eb6d725774b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 30 Nov 2011 18:05:06 +0200 Subject: [PATCH 11/11] rtpdec: Templatize the code for different g726 bitrate variants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/rtpdec_g726.c | 100 +++++++++----------------------------- 1 file changed, 23 insertions(+), 77 deletions(-) diff --git a/libavformat/rtpdec_g726.c b/libavformat/rtpdec_g726.c index 0b7b0f0f94..5735c2cba6 100644 --- a/libavformat/rtpdec_g726.c +++ b/libavformat/rtpdec_g726.c @@ -21,82 +21,28 @@ #include "avformat.h" #include "rtpdec_formats.h" -static int g726_16_init(AVFormatContext *s, int st_index, PayloadContext *data) -{ - AVStream *stream = s->streams[st_index]; - AVCodecContext *codec = stream->codec; - - codec->bit_rate = 16000; - if (codec->sample_rate) - codec->bits_per_coded_sample = - av_clip((codec->bit_rate + codec->sample_rate/2) / codec->sample_rate, 2, 5); - - return 0; +#define RTP_G726_HANDLER(bitrate) \ +static int g726_ ## bitrate ##_init(AVFormatContext *s, int st_index, PayloadContext *data) \ +{ \ + AVStream *stream = s->streams[st_index]; \ + AVCodecContext *codec = stream->codec; \ +\ + codec->bit_rate = bitrate*1000; \ + if (codec->sample_rate) \ + codec->bits_per_coded_sample = \ + av_clip((codec->bit_rate + codec->sample_rate/2) / codec->sample_rate, 2, 5); \ +\ + return 0; \ +} \ +\ +RTPDynamicProtocolHandler ff_g726_ ## bitrate ## _dynamic_handler = { \ + .enc_name = "G726-" #bitrate, \ + .codec_type = AVMEDIA_TYPE_AUDIO, \ + .codec_id = CODEC_ID_ADPCM_G726, \ + .init = g726_ ## bitrate ## _init, \ } -static int g726_24_init(AVFormatContext *s, int st_index, PayloadContext *data) -{ - AVStream *stream = s->streams[st_index]; - AVCodecContext *codec = stream->codec; - - codec->bit_rate = 24000; - if (codec->sample_rate) - codec->bits_per_coded_sample = - av_clip((codec->bit_rate + codec->sample_rate/2) / codec->sample_rate, 2, 5); - - return 0; -} - -static int g726_32_init(AVFormatContext *s, int st_index, PayloadContext *data) -{ - AVStream *stream = s->streams[st_index]; - AVCodecContext *codec = stream->codec; - - codec->bit_rate = 32000; - if (codec->sample_rate) - codec->bits_per_coded_sample = - av_clip((codec->bit_rate + codec->sample_rate/2) / codec->sample_rate, 2, 5); - - return 0; -} - -static int g726_40_init(AVFormatContext *s, int st_index, PayloadContext *data) -{ - AVStream *stream = s->streams[st_index]; - AVCodecContext *codec = stream->codec; - - codec->bit_rate = 40000; - if (codec->sample_rate) - codec->bits_per_coded_sample = - av_clip((codec->bit_rate + codec->sample_rate/2) / codec->sample_rate, 2, 5); - - return 0; -} - -RTPDynamicProtocolHandler ff_g726_16_dynamic_handler = { - .enc_name = "G726-16", - .codec_type = AVMEDIA_TYPE_AUDIO, - .codec_id = CODEC_ID_ADPCM_G726, - .init = g726_16_init, -}; - -RTPDynamicProtocolHandler ff_g726_24_dynamic_handler = { - .enc_name = "G726-24", - .codec_type = AVMEDIA_TYPE_AUDIO, - .codec_id = CODEC_ID_ADPCM_G726, - .init = g726_24_init, -}; - -RTPDynamicProtocolHandler ff_g726_32_dynamic_handler = { - .enc_name = "G726-32", - .codec_type = AVMEDIA_TYPE_AUDIO, - .codec_id = CODEC_ID_ADPCM_G726, - .init = g726_32_init, -}; - -RTPDynamicProtocolHandler ff_g726_40_dynamic_handler = { - .enc_name = "G726-40", - .codec_type = AVMEDIA_TYPE_AUDIO, - .codec_id = CODEC_ID_ADPCM_G726, - .init = g726_40_init, -}; +RTP_G726_HANDLER(16); +RTP_G726_HANDLER(24); +RTP_G726_HANDLER(32); +RTP_G726_HANDLER(40);