From 965cfc6684e00bd7d21295554f325ff62ce6669a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 1 Feb 2022 08:42:25 +0100 Subject: [PATCH] avcodec/mpegvideo: Move decoder-only stuff to a new header Signed-off-by: Andreas Rheinhardt --- libavcodec/dxva2_mpeg2.c | 2 +- libavcodec/dxva2_vc1.c | 1 + libavcodec/h261dec.c | 1 + libavcodec/h263dec.c | 1 + libavcodec/mpeg12dec.c | 1 + libavcodec/mpeg4videodec.c | 1 + libavcodec/mpegvideo.h | 28 ---------------- libavcodec/mpegvideo_dec.c | 1 + libavcodec/mpegvideodec.h | 67 ++++++++++++++++++++++++++++++++++++++ libavcodec/mss2.c | 1 + libavcodec/rv10.c | 1 + libavcodec/rv30.c | 1 + libavcodec/rv34.c | 1 + libavcodec/rv40.c | 1 + libavcodec/vaapi_mpeg2.c | 1 + libavcodec/vaapi_mpeg4.c | 1 + libavcodec/vaapi_vc1.c | 1 + libavcodec/vc1_block.c | 1 + libavcodec/vc1dec.c | 1 + libavcodec/vdpau.c | 1 + 20 files changed, 85 insertions(+), 29 deletions(-) create mode 100644 libavcodec/mpegvideodec.h diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c index 8cc21bf199..136f5f9e06 100644 --- a/libavcodec/dxva2_mpeg2.c +++ b/libavcodec/dxva2_mpeg2.c @@ -24,7 +24,7 @@ #include "dxva2_internal.h" #include "mpegutils.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #define MAX_SLICES 1024 struct dxva2_picture_context { diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index f08ac8b5a0..5fd6957d0c 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -22,6 +22,7 @@ #include "dxva2_internal.h" #include "mpegutils.h" +#include "mpegvideodec.h" #include "vc1.h" #include "vc1data.h" diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index 17f1067b15..5e732b05bf 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -31,6 +31,7 @@ #include "mpeg_er.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "h261.h" #include "internal.h" diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index ecbae0cfe2..09176c2749 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -45,6 +45,7 @@ #endif #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "msmpeg4dec.h" #include "qpeldsp.h" #include "thread.h" diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index b4e4bfa022..f4e39e5d22 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -47,6 +47,7 @@ #include "mpegutils.h" #include "mpegvideo.h" #include "mpegvideodata.h" +#include "mpegvideodec.h" #include "profiles.h" #include "startcode.h" #include "thread.h" diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 34b6ec2078..83550e48b6 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -32,6 +32,7 @@ #include "mpegutils.h" #include "mpegvideo.h" #include "mpegvideodata.h" +#include "mpegvideodec.h" #include "mpeg4video.h" #include "mpeg4videodata.h" #include "mpeg4videodec.h" diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index e16f850f30..c4ac7bc966 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -44,7 +44,6 @@ #include "mpegpicture.h" #include "mpegvideodsp.h" #include "mpegvideoencdsp.h" -#include "mpegvideodata.h" #include "pixblockdsp.h" #include "put_bits.h" #include "ratecontrol.h" @@ -586,31 +585,13 @@ int ff_mpv_init_context_frame(MpegEncContext *s); */ void ff_mpv_free_context_frame(MpegEncContext *s); -int ff_mpv_common_frame_size_change(MpegEncContext *s); void ff_mpv_common_end(MpegEncContext *s); -/** - * Initialize the given MpegEncContext for decoding. - * the changed fields will not depend upon - * the prior state of the MpegEncContext. - */ -void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx); void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64]); -void ff_mpv_report_decode_progress(MpegEncContext *s); - -int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx); -void ff_mpv_frame_end(MpegEncContext *s); void ff_clean_intra_table_entries(MpegEncContext *s); -void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h); -void ff_mpeg_flush(AVCodecContext *avctx); - -void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict); - -int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type); int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src); -int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); void ff_set_qscale(MpegEncContext * s, int qscale); void ff_mpv_idct_init(MpegEncContext *s); @@ -638,13 +619,4 @@ static inline void ff_update_block_index(MpegEncContext *s){ s->dest[2]+= (2 >> s->chroma_x_shift) * block_size; } -static inline int mpeg_get_qscale(MpegEncContext *s) -{ - int qscale = get_bits(&s->gb, 5); - if (s->q_scale_type) - return ff_mpeg2_non_linear_qscale[qscale]; - else - return qscale << 1; -} - #endif /* AVCODEC_MPEGVIDEO_H */ diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index bb581840ae..06d852a77d 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -31,6 +31,7 @@ #include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "threadframe.h" void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx) diff --git a/libavcodec/mpegvideodec.h b/libavcodec/mpegvideodec.h new file mode 100644 index 0000000000..0cda0af733 --- /dev/null +++ b/libavcodec/mpegvideodec.h @@ -0,0 +1,67 @@ +/* + * MPEGVideo decoders header + * Copyright (c) 2000, 2001, 2002 Fabrice Bellard + * Copyright (c) 2002-2004 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * mpegvideo decoder header. + */ + +#ifndef AVCODEC_MPEGVIDEODEC_H +#define AVCODEC_MPEGVIDEODEC_H + +#include "libavutil/frame.h" +#include "avcodec.h" +#include "get_bits.h" +#include "mpegpicture.h" +#include "mpegvideo.h" +#include "mpegvideodata.h" + +/** + * Initialize the given MpegEncContext for decoding. + * the changed fields will not depend upon + * the prior state of the MpegEncContext. + */ +void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx); + +int ff_mpv_common_frame_size_change(MpegEncContext *s); + +int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx); +void ff_mpv_report_decode_progress(MpegEncContext *s); +void ff_mpv_frame_end(MpegEncContext *s); + +int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type); +int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); +void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h); +void ff_mpeg_flush(AVCodecContext *avctx); + +void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict); + +static inline int mpeg_get_qscale(MpegEncContext *s) +{ + int qscale = get_bits(&s->gb, 5); + if (s->q_scale_type) + return ff_mpeg2_non_linear_qscale[qscale]; + else + return qscale << 1; +} + +#endif /* AVCODEC_MPEGVIDEODEC_H */ diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index dcf91f9828..65decf0a3c 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -27,6 +27,7 @@ #include "error_resilience.h" #include "internal.h" #include "mpeg_er.h" +#include "mpegvideodec.h" #include "msmpeg4dec.h" #include "qpeldsp.h" #include "vc1.h" diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 241ee53442..26cb9a2294 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -39,6 +39,7 @@ #include "mpeg_er.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "mpeg4video.h" #include "mpegvideodata.h" #include "rv10dec.h" diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index d11b8430e7..c84e09dd1a 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -28,6 +28,7 @@ #include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "golomb.h" #include "rv34.h" diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 1a0ca6b520..1fb17ddb90 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -35,6 +35,7 @@ #include "error_resilience.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "golomb.h" #include "internal.h" #include "mathops.h" diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 0b3f733bc6..9cec0751e1 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -32,6 +32,7 @@ #include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "golomb.h" #include "rv34.h" diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c index ba70ddef31..5e2b889137 100644 --- a/libavcodec/vaapi_mpeg2.c +++ b/libavcodec/vaapi_mpeg2.c @@ -23,6 +23,7 @@ #include "hwconfig.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "vaapi_decode.h" /** Reconstruct bitstream f_code */ diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index fc0faf0932..d2d9b9b322 100644 --- a/libavcodec/vaapi_mpeg4.c +++ b/libavcodec/vaapi_mpeg4.c @@ -24,6 +24,7 @@ #include "hwconfig.h" #include "mpeg4videodec.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "vaapi_decode.h" /** Reconstruct bitstream intra_dc_vlc_thr */ diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c index d82b5b31f8..76e0a1e941 100644 --- a/libavcodec/vaapi_vc1.c +++ b/libavcodec/vaapi_vc1.c @@ -21,6 +21,7 @@ */ #include "hwconfig.h" +#include "mpegvideodec.h" #include "vaapi_decode.h" #include "vc1.h" #include "vc1data.h" diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c index c922efe4c8..119df4081d 100644 --- a/libavcodec/vc1_block.c +++ b/libavcodec/vc1_block.c @@ -29,6 +29,7 @@ #include "avcodec.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "msmpeg4data.h" #include "unary.h" #include "vc1.h" diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 89cccc1929..700c787d99 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -33,6 +33,7 @@ #include "internal.h" #include "mpeg_er.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "msmpeg4data.h" #include "msmpeg4dec.h" #include "profiles.h" diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index f96ac15e2a..5072071c70 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -26,6 +26,7 @@ #include "avcodec.h" #include "decode.h" #include "internal.h" +#include "mpegvideodec.h" #include "vc1.h" #include "vdpau.h" #include "vdpau_internal.h"