1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avcodec/h26[134]dec: Always report the buffer to be completely consumed

It is pointless to try to report the true number because
decode_simple_internal() always treats the buffer as
completely consumed for video codecs anyway.
(Apart from that: The h263dec code would report to only
have consumed the header data in case decoding is aborted
due to skip_frame which makes no sense.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-02-24 19:30:27 +01:00
parent 78b26225ba
commit e6657d499a
3 changed files with 6 additions and 56 deletions

View File

@ -536,20 +536,6 @@ static int h261_decode_gob(H261DecContext *h)
return -1;
}
/**
* returns the number of bytes consumed for building the current frame
*/
static int get_consumed_bytes(MpegEncContext *s, int buf_size)
{
int pos = get_bits_count(&s->gb) >> 3;
if (pos == 0)
pos = 1; // avoid infinite loops (i doubt that is needed but ...)
if (pos + 10 > buf_size)
pos = buf_size; // oops ;)
return pos;
}
static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict,
int *got_frame, AVPacket *avpkt)
{
@ -615,7 +601,7 @@ static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict,
*got_frame = 1;
return get_consumed_bytes(s, buf_size);
return buf_size;
}
const FFCodec ff_h261_decoder = {

View File

@ -170,29 +170,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
return 0;
}
/**
* Return the number of bytes consumed for building the current frame.
*/
static int get_consumed_bytes(MpegEncContext *s, int buf_size)
{
int pos = (get_bits_count(&s->gb) + 7) >> 3;
if (s->divx_packed || s->avctx->hwaccel) {
/* We would have to scan through the whole buf to handle the weird
* reordering ... */
return buf_size;
} else {
// avoid infinite loops (maybe not needed...)
if (pos == 0)
pos = 1;
// oops ;)
if (pos + 10 > buf_size)
pos = buf_size;
return pos;
}
}
static int decode_slice(MpegEncContext *s)
{
const int part_mask = s->partitioned_frame
@ -523,7 +500,7 @@ retry:
}
}
if (ret == FRAME_SKIPPED)
return get_consumed_bytes(s, buf_size);
return buf_size;
/* skip if the header was thrashed */
if (ret < 0) {
@ -587,13 +564,13 @@ retry:
/* skip B-frames if we don't have reference frames */
if (!s->last_pic.ptr &&
(s->pict_type == AV_PICTURE_TYPE_B || s->droppable))
return get_consumed_bytes(s, buf_size);
return buf_size;
if ((avctx->skip_frame >= AVDISCARD_NONREF &&
s->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY &&
s->pict_type != AV_PICTURE_TYPE_I) ||
avctx->skip_frame >= AVDISCARD_ALL)
return get_consumed_bytes(s, buf_size);
return buf_size;
if ((ret = ff_mpv_frame_start(s, avctx)) < 0)
return ret;
@ -702,7 +679,7 @@ frame_end:
if (slice_ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
return slice_ret;
else
return get_consumed_bytes(s, buf_size);
return buf_size;
}
static const AVCodecHWConfigInternal *const h263_hw_config_list[] = {

View File

@ -827,19 +827,6 @@ end:
return (ret < 0) ? ret : buf_size;
}
/**
* Return the number of bytes consumed for building the current frame.
*/
static int get_consumed_bytes(int pos, int buf_size)
{
if (pos == 0)
pos = 1; // avoid infinite loops (I doubt that is needed but...)
if (pos + 10 > buf_size)
pos = buf_size; // oops ;)
return pos;
}
static int h264_export_enc_params(AVFrame *f, const H264Picture *p)
{
AVVideoEncParams *par;
@ -1100,7 +1087,7 @@ static int h264_decode_frame(AVCodecContext *avctx, AVFrame *pict,
ff_h264_unref_picture(&h->last_pic_for_ec);
return get_consumed_bytes(buf_index, buf_size);
return buf_size;
}
#define OFFSET(x) offsetof(H264Context, x)