From 64e4386974b976070fc22ec3153e163de4a3e14e Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 2 Mar 2013 11:22:02 -0800 Subject: [PATCH 1/2] h264: Integrate draw_horiz_band into ff_h264_draw_horiz_band MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the decoder independent of mpegvideo. This copy of the draw_horiz_band code is simplified compared to the "generic" mpegvideo one which still has a number of special cases for different codecs. Signed-off-by: Martin Storsjö --- configure | 4 ++-- libavcodec/h264.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 2435a62c67..2843fc6495 100755 --- a/configure +++ b/configure @@ -1542,7 +1542,7 @@ h263_decoder_select="error_resilience h263_parser mpegvideo" h263_encoder_select="aandcttables error_resilience mpegvideoenc" h263i_decoder_select="h263_decoder" h263p_encoder_select="h263_encoder" -h264_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo" +h264_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel videodsp" huffyuv_encoder_select="huffman" iac_decoder_select="fft mdct sinewin" imc_decoder_select="fft mdct sinewin" @@ -1689,7 +1689,7 @@ wmv3_vdpau_decoder_select="vc1_vdpau_decoder" wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel" # parsers -h264_parser_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo" +h264_parser_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel videodsp" mpeg4video_parser_select="error_resilience mpegvideo" mpegvideo_parser_select="error_resilience mpegvideo" vc1_parser_select="error_resilience mpegvideo" diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 610c815732..24d9c96276 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -123,10 +123,46 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, void ff_h264_draw_horiz_band(H264Context *h, int y, int height) { - ff_draw_horiz_band(h->avctx, NULL, &h->cur_pic, - h->ref_list[0][0].f.data[0] ? &h->ref_list[0][0] : NULL, - y, height, h->picture_structure, h->first_field, 0, - h->low_delay, h->mb_height * 16, h->mb_width * 16); + AVCodecContext *avctx = h->avctx; + Picture *cur = &h->cur_pic; + Picture *last = h->ref_list[0][0].f.data[0] ? &h->ref_list[0][0] : NULL; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); + int vshift = desc->log2_chroma_h; + const int field_pic = h->picture_structure != PICT_FRAME; + if (field_pic) { + height <<= 1; + y <<= 1; + } + + height = FFMIN(height, avctx->height - y); + + if (field_pic && h->first_field && !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) + return; + + if (avctx->draw_horiz_band) { + AVFrame *src; + int offset[AV_NUM_DATA_POINTERS]; + int i; + + if (cur->f.pict_type == AV_PICTURE_TYPE_B || h->low_delay || + (avctx->slice_flags & SLICE_FLAG_CODED_ORDER)) + src = &cur->f; + else if (last) + src = &last->f; + else + return; + + offset[0] = y * src->linesize[0]; + offset[1] = + offset[2] = (y >> vshift) * src->linesize[1]; + for (i = 3; i < AV_NUM_DATA_POINTERS; i++) + offset[i] = 0; + + emms_c(); + + avctx->draw_horiz_band(avctx, src, offset, + y, h->picture_structure, height); + } } static void free_frame_buffer(H264Context *h, Picture *pic) From 54b298fe5650c124c29a8283cfd05024ac409d3a Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 3 Mar 2013 08:23:08 -0800 Subject: [PATCH 2/2] lavc: Deprecate the deinterlace functions in libavcodec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- avconv.c | 4 ++++ avconv_opt.c | 4 ++++ libavcodec/avcodec.h | 5 +++++ libavcodec/imgconvert.c | 4 ++++ libavcodec/version.h | 3 +++ 5 files changed, 20 insertions(+) diff --git a/avconv.c b/avconv.c index 75a8f0d5ec..900f49afe7 100644 --- a/avconv.c +++ b/avconv.c @@ -404,6 +404,7 @@ static void do_audio_out(AVFormatContext *s, OutputStream *ost, } } +#if FF_API_DEINTERLACE static void pre_process_video_frame(InputStream *ist, AVPicture *picture, void **bufp) { AVCodecContext *dec; @@ -442,6 +443,7 @@ static void pre_process_video_frame(InputStream *ist, AVPicture *picture, void * *picture = *picture2; *bufp = buf; } +#endif static void do_subtitle_out(AVFormatContext *s, OutputStream *ost, @@ -1181,7 +1183,9 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts, decoded_frame->pkt_dts); pkt->size = 0; +#if FF_API_DEINTERLACE pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free); +#endif rate_emu_sleep(ist); diff --git a/avconv_opt.c b/avconv_opt.c index 7c58f49e3b..5bb7fb75f5 100644 --- a/avconv_opt.c +++ b/avconv_opt.c @@ -1715,12 +1715,14 @@ static int opt_vsync(void *optctx, const char *opt, const char *arg) return 0; } +#if FF_API_DEINTERLACE static int opt_deinterlace(void *optctx, const char *opt, const char *arg) { av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -filter:v yadif instead\n", opt); do_deinterlace = 1; return 0; } +#endif int opt_cpuflags(void *optctx, const char *opt, const char *arg) { @@ -2057,8 +2059,10 @@ const OptionDef options[] = { "select the pass number (1 or 2)", "n" }, { "passlogfile", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC, { .off = OFFSET(passlogfiles) }, "select two pass log file name prefix", "prefix" }, +#if FF_API_DEINTERLACE { "deinterlace", OPT_VIDEO | OPT_EXPERT , { .func_arg = opt_deinterlace }, "this option is deprecated, use the yadif filter instead" }, +#endif { "vstats", OPT_VIDEO | OPT_EXPERT , { &opt_vstats }, "dump video coding statistics to file" }, { "vstats_file", OPT_VIDEO | HAS_ARG | OPT_EXPERT , { opt_vstats_file }, diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7a2477516d..120bfbcaae 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -4267,11 +4267,16 @@ int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt, */ int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height); +#if FF_API_DEINTERLACE /** * deinterlace - if not supported return -1 + * + * @deprecated - use yadif (in libavfilter) instead */ +attribute_deprecated int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, enum AVPixelFormat pix_fmt, int width, int height); +#endif /** * Copy image src to dst. Wraps av_picture_data_copy() above. */ diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 36c24dfa88..8f8b6e3914 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -366,6 +366,8 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, return 0; } +#if FF_API_DEINTERLACE + #if !HAVE_MMX_EXTERNAL /* filter parameters: [-1 4 2 4 -1] // 8 */ static void deinterlace_line_c(uint8_t *dst, @@ -524,3 +526,5 @@ int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, emms_c(); return 0; } + +#endif /* FF_API_DEINTERLACE */ diff --git a/libavcodec/version.h b/libavcodec/version.h index 7a024d38a1..5b65c2d6a0 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -97,5 +97,8 @@ #ifndef FF_API_IDCT #define FF_API_IDCT (LIBAVCODEC_VERSION_MAJOR < 55) #endif +#ifndef FF_API_DEINTERLACE +#define FF_API_DEINTERLACE (LIBAVCODEC_VERSION_MAJOR < 56) +#endif #endif /* AVCODEC_VERSION_H */