diff mbox series

[FFmpeg-devel,v2,27/69] avcodec/mpegvideo_enc: Don't find encoder by ID

Message ID AM7PR03MB66609447A643E3DADB6A6BC48F269@AM7PR03MB6660.eurprd03.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel,v2,01/69] avcodec/avcodec: Avoid MpegEncContext in AVHWAccel.decode_mb | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 1, 2022, 1:06 p.m. UTC
mpegvideo-based encoders supporting bframes implement this
by opening encoders of their own to test how long the chains
of bframes are supposed to be. The needed AVCodec was obtained
via avcodec_find_encoder(). This is complicated, as the current
encoder can be directly obtained. And it also is not guaranteed
that one actually gets the current encoder or not another encoder
for the same codec ID (the latter does not seem to be the case now).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_enc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 20c61dc0a6..5bf135bccf 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1218,7 +1218,6 @@  static int encode_frame(AVCodecContext *c, AVFrame *frame, AVPacket *pkt)
 
 static int estimate_best_b_count(MPVMainEncContext *s)
 {
-    const AVCodec *codec = avcodec_find_encoder(s->avctx->codec_id);
     AVPacket *pkt;
     const int scale = s->brd_scale;
     int width  = s->width  >> scale;
@@ -1302,7 +1301,7 @@  static int estimate_best_b_count(MPVMainEncContext *s)
         c->time_base    = s->avctx->time_base;
         c->max_b_frames = s->max_b_frames;
 
-        ret = avcodec_open2(c, codec, NULL);
+        ret = avcodec_open2(c, s->avctx->codec, NULL);
         if (ret < 0)
             goto fail;