diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 49c284ef9e..3e6f000868 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -566,14 +566,14 @@ OBJS-$(CONFIG_MPC7_DECODER) += mpc7.o mpc.o OBJS-$(CONFIG_MPC8_DECODER) += mpc8.o mpc.o OBJS-$(CONFIG_MPEGVIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o -OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o +OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o OBJS-$(CONFIG_MPEG1_CUVID_DECODER) += cuviddec.o OBJS-$(CONFIG_MPEG1_V4L2M2M_DECODER) += v4l2_m2m_dec.o OBJS-$(CONFIG_MPEG2_MMAL_DECODER) += mmaldec.o OBJS-$(CONFIG_MPEG2_QSV_DECODER) += qsvdec.o OBJS-$(CONFIG_MPEG2_QSV_ENCODER) += qsvenc_mpeg2.o OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o -OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o +OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o OBJS-$(CONFIG_MPEG2_CUVID_DECODER) += cuviddec.o OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER) += vaapi_encode_mpeg2.o diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 62a77b6806..61723f3a29 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -30,8 +30,6 @@ #include "libavutil/attributes.h" #include "libavutil/thread.h" -#include "mpegvideo.h" -#include "mpeg12codecs.h" #include "mpeg12data.h" #include "mpeg12dec.h" #include "mpegutils.h" @@ -122,14 +120,6 @@ av_cold void ff_init_2d_vlc_rl(const uint16_t table_vlc[][2], RL_VLC_ELEM rl_vlc } } -void ff_mpeg1_clean_buffers(MpegEncContext *s) -{ - s->last_dc[0] = 1 << (7 + s->intra_dc_precision); - s->last_dc[1] = s->last_dc[0]; - s->last_dc[2] = s->last_dc[0]; - memset(s->last_mv, 0, sizeof(s->last_mv)); -} - /******************************************/ /* decoding */ diff --git a/libavcodec/mpeg12codecs.h b/libavcodec/mpeg12codecs.h deleted file mode 100644 index f8cf5503e2..0000000000 --- a/libavcodec/mpeg12codecs.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * MPEG-1/2 codecs common code - * Copyright (c) 2007 Aurelien Jacobs - * - * 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 - */ - -#ifndef AVCODEC_MPEG12CODECS_H -#define AVCODEC_MPEG12CODECS_H - -#include "mpegvideo.h" - -void ff_mpeg1_clean_buffers(MpegEncContext *s); - -#endif /* AVCODEC_MPEG12CODECS_H */ diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 3ea8d02e1b..58ff925bfd 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -50,7 +50,6 @@ #include "idctdsp.h" #include "mpeg_er.h" #include "mpeg12.h" -#include "mpeg12codecs.h" #include "mpeg12data.h" #include "mpeg12dec.h" #include "mpegutils.h" @@ -1375,7 +1374,6 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const s, int mb_y, if (s->c.codec_id != AV_CODEC_ID_MPEG1VIDEO && s->c.mb_height > 2800/16) skip_bits(&s->gb, 3); - ff_mpeg1_clean_buffers(&s->c); s->c.interlaced_dct = 0; s->c.qscale = mpeg_get_qscale(&s->gb, s->c.q_scale_type); @@ -1455,6 +1453,11 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const s, int mb_y, } } + s->c.last_dc[0] = 128 << s->c.intra_dc_precision; + s->c.last_dc[1] = s->c.last_dc[0]; + s->c.last_dc[2] = s->c.last_dc[0]; + memset(s->c.last_mv, 0, sizeof(s->c.last_mv)); + for (int mb_skip_run = 0;;) { ret = mpeg_decode_mb(s, &mb_skip_run); if (ret < 0) diff --git a/libavcodec/mpeg12enc.h b/libavcodec/mpeg12enc.h index a8aeadbb3e..97007be8fe 100644 --- a/libavcodec/mpeg12enc.h +++ b/libavcodec/mpeg12enc.h @@ -36,4 +36,12 @@ static inline void ff_mpeg1_encode_init(MPVEncContext *s) s->c.c_dc_scale_table = ff_mpeg12_dc_scale_table[s->c.intra_dc_precision]; } +static inline void ff_mpeg1_clean_buffers(MPVEncContext *s) +{ + s->c.last_dc[0] = 128 << s->c.intra_dc_precision; + s->c.last_dc[1] = s->c.last_dc[0]; + s->c.last_dc[2] = s->c.last_dc[0]; + memset(s->c.last_mv, 0, sizeof(s->c.last_mv)); +} + #endif /* AVCODEC_MPEG12ENC_H */ diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 9e83026b51..8015886dc4 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -47,7 +47,6 @@ #include "avcodec.h" #include "encode.h" #include "idctdsp.h" -#include "mpeg12codecs.h" #include "mpeg12data.h" #include "mpeg12enc.h" #include "mpegvideo.h" @@ -3144,7 +3143,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ case AV_CODEC_ID_MPEG2VIDEO: if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) { ff_mpeg1_encode_slice_header(s); - ff_mpeg1_clean_buffers(&s->c); + ff_mpeg1_clean_buffers(s); } break; #if CONFIG_H263P_ENCODER