summaryrefslogtreecommitdiff
path: root/libavcodec/encode.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-03-30 23:28:24 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-04-05 20:02:37 +0200
commit4243da4ff42e306b3622b181e12f5cd127d21414 (patch)
treea74a6b85a179795431a0ee2b259be8c35f0ed799 /libavcodec/encode.c
parentce7dbd0481f990e249c2a05f179228489d3062cf (diff)
downloadffmpeg-4243da4ff42e306b3622b181e12f5cd127d21414.tar.gz
avcodec/codec_internal: Use union for FFCodec decode/encode callbacks
This is possible, because every given FFCodec has to implement exactly one of these. Doing so decreases sizeof(FFCodec) and therefore decreases the size of the binary. Notice that in case of position-independent code the decrease is in .data.rel.ro, so that this translates to decreased memory consumption. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/encode.c')
-rw-r--r--libavcodec/encode.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 70bd8da81f..3891ebcc91 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -152,7 +152,7 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
return -1;
}
- ret = ffcodec(avctx->codec)->encode_sub(avctx, buf, buf_size, sub);
+ ret = ffcodec(avctx->codec)->cb.encode_sub(avctx, buf, buf_size, sub);
avctx->frame_number++;
return ret;
}
@@ -202,7 +202,7 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
got_packet = 0;
- av_assert0(codec->encode2);
+ av_assert0(codec->cb_type == FF_CODEC_CB_TYPE_ENCODE);
if (CONFIG_FRAME_THREAD_ENCODER &&
avci->frame_thread_encoder && (avctx->active_thread_type & FF_THREAD_FRAME))
@@ -212,7 +212,7 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
* no sense to use the properties of the current frame anyway). */
ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet);
else {
- ret = codec->encode2(avctx, avpkt, frame, &got_packet);
+ ret = codec->cb.encode(avctx, avpkt, frame, &got_packet);
if (avctx->codec->type == AVMEDIA_TYPE_VIDEO && !ret && got_packet &&
!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))
avpkt->pts = avpkt->dts = frame->pts;
@@ -292,8 +292,8 @@ static int encode_receive_packet_internal(AVCodecContext *avctx, AVPacket *avpkt
return AVERROR(EINVAL);
}
- if (ffcodec(avctx->codec)->receive_packet) {
- ret = ffcodec(avctx->codec)->receive_packet(avctx, avpkt);
+ if (ffcodec(avctx->codec)->cb_type == FF_CODEC_CB_TYPE_RECEIVE_PACKET) {
+ ret = ffcodec(avctx->codec)->cb.receive_packet(avctx, avpkt);
if (ret < 0)
av_packet_unref(avpkt);
else