mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-23 15:30:01 +01:00
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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user