From 679481b3b61dda5e2827f9757bf8c12a8de193c9 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 10 Apr 2012 14:27:59 +0200 Subject: [PATCH 1/5] Drop some pointless #ifdefs. The files are only compiled if the #ifdef conditions are met. --- libavcodec/libxvidff.c | 4 ---- libavcodec/snowenc.c | 2 -- libavformat/nutdec.c | 2 -- 3 files changed, 8 deletions(-) diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c index b003d7e8e3..344f6033ff 100644 --- a/libavcodec/libxvidff.c +++ b/libavcodec/libxvidff.c @@ -114,8 +114,6 @@ int ff_tempfile(const char *prefix, char **filename) { return fd; /* success */ } -#if CONFIG_LIBXVID_ENCODER - /** * Create the private context for the encoder. * All buffers are allocated, settings are loaded from the user, @@ -830,5 +828,3 @@ AVCodec ff_libxvid_encoder = { .pix_fmts = (const enum PixelFormat[]){ PIX_FMT_YUV420P, PIX_FMT_NONE }, .long_name = NULL_IF_CONFIG_SMALL("libxvidcore MPEG-4 part 2"), }; - -#endif /* CONFIG_LIBXVID_ENCODER */ diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 03d0afcab0..7b010e1f1c 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -152,7 +152,6 @@ static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, i #endif /* QUANTIZE2==1 */ -#if CONFIG_SNOW_ENCODER static av_cold int encode_init(AVCodecContext *avctx) { SnowContext *s = avctx->priv_data; @@ -1925,4 +1924,3 @@ AVCodec ff_snow_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Snow"), .priv_class = &snowenc_class, }; -#endif diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 32db763a67..004a2ea255 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -985,7 +985,6 @@ static int nut_read_close(AVFormatContext *s) return 0; } -#if CONFIG_NUT_DEMUXER AVInputFormat ff_nut_demuxer = { .name = "nut", .long_name = NULL_IF_CONFIG_SMALL("NUT format"), @@ -1001,4 +1000,3 @@ AVInputFormat ff_nut_demuxer = { ff_nut_subtitle_tags, 0 }, }; -#endif From 9676d8eb67b00e1bb52e448c20c8f5cb6ad5e1ef Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 10 Apr 2012 18:18:40 +0200 Subject: [PATCH 2/5] interplayvideo: fix av_dlog parameter type mismatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libavcodec/interplayvideo.c:909:13: warning: format ‘%p’ expects argument of type ‘void *’, but argument 7 has type ‘GetByteContext’ [-Wformat] --- libavcodec/interplayvideo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index 4732bf5325..bee7a68e52 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -907,8 +907,9 @@ static void ipvideo_decode_opcodes(IpvideoContext *s) for (x = 0; x < s->avctx->width; x += 8) { opcode = get_bits(&gb, 4); - av_dlog(NULL, " block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n", - x, y, opcode, s->stream_ptr); + av_dlog(s->avctx, + " block @ (%3d, %3d): encoding 0x%X, data ptr offset %d\n", + x, y, opcode, bytestream2_tell(&s->stream_ptr)); if (!s->is_16bpp) { s->pixel_ptr = s->current_frame.data[0] + x From 18b59956e0e94017f1b519bb42c7c937b2f9f8a4 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Wed, 11 Apr 2012 03:37:13 -0700 Subject: [PATCH 3/5] movenc: remove redundant check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The proper check is already in mov_write_header. Signed-off-by: Martin Storsjö --- libavformat/movenc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 5777443db2..ce656148a5 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2816,9 +2816,6 @@ static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt) uint8_t *reformatted_data = NULL; int64_t frag_duration = 0; - if (!s->pb->seekable && !(mov->flags & FF_MOV_FLAG_EMPTY_MOOV)) - return 0; /* Can't handle that */ - if (!size) return 0; /* Discard 0 sized packets */ if (trk->entry) From ebbede22657a17c40f913857b23c8de85e75fe5c Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Wed, 11 Apr 2012 03:37:14 -0700 Subject: [PATCH 4/5] movenc: small refactor mov_write_packet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Share the formerly internal write_packet with the hinter and move the fragment flush logic to the user facing one since it is not concerned about movtrack-only streams. Fixes bug #263 Signed-off-by: Martin Storsjö --- libavformat/movenc.c | 59 ++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index ce656148a5..e4dbbc99da 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2805,7 +2805,7 @@ static int mov_flush_fragment(AVFormatContext *s) return 0; } -static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt) +int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; AVIOContext *pb = s->pb; @@ -2814,23 +2814,6 @@ static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt) unsigned int samples_in_chunk = 0; int size= pkt->size; uint8_t *reformatted_data = NULL; - int64_t frag_duration = 0; - - if (!size) return 0; /* Discard 0 sized packets */ - - if (trk->entry) - frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts, - s->streams[pkt->stream_index]->time_base, - AV_TIME_BASE_Q); - if ((mov->max_fragment_duration && - frag_duration >= mov->max_fragment_duration) || - (mov->max_fragment_size && mov->mdat_size + size >= mov->max_fragment_size) || - (mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME && - enc->codec_type == AVMEDIA_TYPE_VIDEO && - trk->entry && pkt->flags & AV_PKT_FLAG_KEY)) { - if (frag_duration >= mov->min_fragment_duration) - mov_flush_fragment(s); - } if (mov->flags & FF_MOV_FLAG_FRAGMENT) { int ret; @@ -2956,13 +2939,35 @@ static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt) return 0; } -int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) +static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) { if (!pkt) { mov_flush_fragment(s); return 1; } else { - return mov_write_packet_internal(s, pkt); + MOVMuxContext *mov = s->priv_data; + MOVTrack *trk = &mov->tracks[pkt->stream_index]; + AVCodecContext *enc = trk->enc; + int64_t frag_duration = 0; + int size = pkt->size; + + if (!pkt->size) return 0; /* Discard 0 sized packets */ + + if (trk->entry) + frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts, + s->streams[pkt->stream_index]->time_base, + AV_TIME_BASE_Q); + if ((mov->max_fragment_duration && + frag_duration >= mov->max_fragment_duration) || + (mov->max_fragment_size && mov->mdat_size + size >= mov->max_fragment_size) || + (mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME && + enc->codec_type == AVMEDIA_TYPE_VIDEO && + trk->entry && pkt->flags & AV_PKT_FLAG_KEY)) { + if (frag_duration >= mov->min_fragment_duration) + mov_flush_fragment(s); + } + + return ff_mov_write_packet(s, pkt); } } @@ -3274,7 +3279,7 @@ AVOutputFormat ff_mov_muxer = { .video_codec = CODEC_ID_MPEG4, #endif .write_header = mov_write_header, - .write_packet = ff_mov_write_packet, + .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH, .codec_tag = (const AVCodecTag* const []){ @@ -3293,7 +3298,7 @@ AVOutputFormat ff_tgp_muxer = { .audio_codec = CODEC_ID_AMR_NB, .video_codec = CODEC_ID_H263, .write_header = mov_write_header, - .write_packet = ff_mov_write_packet, + .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH, .codec_tag = (const AVCodecTag* const []){ codec_3gp_tags, 0 }, @@ -3315,7 +3320,7 @@ AVOutputFormat ff_mp4_muxer = { .video_codec = CODEC_ID_MPEG4, #endif .write_header = mov_write_header, - .write_packet = ff_mov_write_packet, + .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH, .codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 }, @@ -3336,7 +3341,7 @@ AVOutputFormat ff_psp_muxer = { .video_codec = CODEC_ID_MPEG4, #endif .write_header = mov_write_header, - .write_packet = ff_mov_write_packet, + .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH, .codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 }, @@ -3353,7 +3358,7 @@ AVOutputFormat ff_tg2_muxer = { .audio_codec = CODEC_ID_AMR_NB, .video_codec = CODEC_ID_H263, .write_header = mov_write_header, - .write_packet = ff_mov_write_packet, + .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH, .codec_tag = (const AVCodecTag* const []){ codec_3gp_tags, 0 }, @@ -3371,7 +3376,7 @@ AVOutputFormat ff_ipod_muxer = { .audio_codec = CODEC_ID_AAC, .video_codec = CODEC_ID_H264, .write_header = mov_write_header, - .write_packet = ff_mov_write_packet, + .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH, .codec_tag = (const AVCodecTag* const []){ codec_ipod_tags, 0 }, @@ -3389,7 +3394,7 @@ AVOutputFormat ff_ismv_muxer = { .audio_codec = CODEC_ID_AAC, .video_codec = CODEC_ID_H264, .write_header = mov_write_header, - .write_packet = ff_mov_write_packet, + .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH, .codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 }, From e1ce756844e684876318570dcebc74bc66c084f0 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Tue, 10 Apr 2012 18:18:53 -0700 Subject: [PATCH 5/5] avplay: Don't free video filters string until the end of decoding. av_freep()ing inside configure_video_filters() leaves a dangling reference in the calling code, and the filter string is needed again when reconfiguring video filters for a size change. --- avplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avplay.c b/avplay.c index d1cf53d117..488d0fcd13 100644 --- a/avplay.c +++ b/avplay.c @@ -1731,7 +1731,6 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0) return ret; - av_freep(&vfilters); } else { if ((ret = avfilter_link(filt_src, 0, filt_out, 0)) < 0) return ret; @@ -1831,6 +1830,7 @@ static int video_thread(void *arg) } the_end: #if CONFIG_AVFILTER + av_freep(&vfilters); avfilter_graph_free(&graph); #endif av_free(frame);