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

avcodec/{h263,mpeg4video}dec: Pass MPVContext*, not Mpeg4DecContext*

The code in h263dec.c is not supposed to know that the MPEG-4
decoder uses an Mpeg4DecContext as private context at all
(said context is only exposed in a header so that hardware
accelerations can access it and for the parser to use).
Passing an MPVContext* directly also allows to remove
the indirection via AVCodecContext.priv_data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-06-19 16:07:48 +02:00
parent 91e9578025
commit 758c8dffc9
4 changed files with 13 additions and 13 deletions

View File

@ -194,7 +194,7 @@ static int decode_slice(MpegEncContext *s)
ff_set_qscale(s, s->qscale); ff_set_qscale(s, s->qscale);
if (s->studio_profile) { if (s->studio_profile) {
if ((ret = ff_mpeg4_decode_studio_slice_header(s->avctx->priv_data)) < 0) if ((ret = ff_mpeg4_decode_studio_slice_header(s)) < 0)
return ret; return ret;
} }
@ -210,7 +210,7 @@ static int decode_slice(MpegEncContext *s)
const int qscale = s->qscale; const int qscale = s->qscale;
if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4) if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4)
if ((ret = ff_mpeg4_decode_partitions(s->avctx->priv_data)) < 0) if ((ret = ff_mpeg4_decode_partitions(s)) < 0)
return ret; return ret;
/* restore variables which were modified */ /* restore variables which were modified */

View File

@ -240,7 +240,7 @@ int ff_h263_resync(MpegEncContext *s){
if(show_bits(&s->gb, 16)==0){ if(show_bits(&s->gb, 16)==0){
pos= get_bits_count(&s->gb); pos= get_bits_count(&s->gb);
if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4) if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4)
ret= ff_mpeg4_decode_video_packet_header(s->avctx->priv_data); ret = ff_mpeg4_decode_video_packet_header(s);
else else
ret= h263_decode_gob_header(s); ret= h263_decode_gob_header(s);
if(ret>=0) if(ret>=0)
@ -257,7 +257,7 @@ int ff_h263_resync(MpegEncContext *s){
pos= get_bits_count(&s->gb); pos= get_bits_count(&s->gb);
if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4) if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4)
ret= ff_mpeg4_decode_video_packet_header(s->avctx->priv_data); ret = ff_mpeg4_decode_video_packet_header(s);
else else
ret= h263_decode_gob_header(s); ret= h263_decode_gob_header(s);
if(ret>=0) if(ret>=0)

View File

@ -700,9 +700,9 @@ static int decode_new_pred(Mpeg4DecContext *ctx, GetBitContext *gb) {
* Decode the next video packet. * Decode the next video packet.
* @return <0 if something went wrong * @return <0 if something went wrong
*/ */
int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx) int ff_mpeg4_decode_video_packet_header(MPVContext *const s)
{ {
MpegEncContext *s = &ctx->m; Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
int mb_num_bits = av_log2(s->mb_num - 1) + 1; int mb_num_bits = av_log2(s->mb_num - 1) + 1;
int header_extension = 0, mb_num, len; int header_extension = 0, mb_num, len;
@ -799,9 +799,9 @@ static void reset_studio_dc_predictors(MpegEncContext *s)
* Decode the next video packet. * Decode the next video packet.
* @return <0 if something went wrong * @return <0 if something went wrong
*/ */
int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx) int ff_mpeg4_decode_studio_slice_header(MPVContext *const s)
{ {
MpegEncContext *s = &ctx->m; Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
GetBitContext *gb = &s->gb; GetBitContext *gb = &s->gb;
unsigned vlc_len; unsigned vlc_len;
uint16_t mb_num; uint16_t mb_num;
@ -1307,9 +1307,9 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count)
* Decode the first and second partition. * Decode the first and second partition.
* @return <0 if error (and sets error type in the error_status_table) * @return <0 if error (and sets error type in the error_status_table)
*/ */
int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx) int ff_mpeg4_decode_partitions(MPVContext *const s)
{ {
MpegEncContext *s = &ctx->m; Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
int mb_num; int mb_num;
int ret; int ret;
const int part_a_error = s->pict_type == AV_PICTURE_TYPE_I ? (ER_DC_ERROR | ER_MV_ERROR) : ER_MV_ERROR; const int part_a_error = s->pict_type == AV_PICTURE_TYPE_I ? (ER_DC_ERROR | ER_MV_ERROR) : ER_MV_ERROR;

View File

@ -116,9 +116,9 @@ void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb
void ff_mpeg4_mcsel_motion(MpegEncContext *s, void ff_mpeg4_mcsel_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
uint8_t *const *ref_picture); uint8_t *const *ref_picture);
int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx); int ff_mpeg4_decode_partitions(MPVContext *const s);
int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx); int ff_mpeg4_decode_video_packet_header(MPVContext *const s);
int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx); int ff_mpeg4_decode_studio_slice_header(MPVContext *const s);
void ff_mpeg4_workaround_bugs(AVCodecContext *avctx); void ff_mpeg4_workaround_bugs(AVCodecContext *avctx);
void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n,
int dir); int dir);