You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/h263dec: Use function ptr for decode_picture_header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -121,6 +121,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
|
|||||||
case AV_CODEC_ID_H263:
|
case AV_CODEC_ID_H263:
|
||||||
case AV_CODEC_ID_H263P:
|
case AV_CODEC_ID_H263P:
|
||||||
avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
|
avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
|
||||||
|
h->decode_header = ff_h263_decode_picture_header;
|
||||||
break;
|
break;
|
||||||
case AV_CODEC_ID_MPEG4:
|
case AV_CODEC_ID_MPEG4:
|
||||||
break;
|
break;
|
||||||
@ -144,13 +145,20 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
|
|||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
s->msmpeg4_version = MSMP4_WMV2;
|
s->msmpeg4_version = MSMP4_WMV2;
|
||||||
break;
|
break;
|
||||||
case AV_CODEC_ID_H263I:
|
|
||||||
case AV_CODEC_ID_RV10:
|
case AV_CODEC_ID_RV10:
|
||||||
case AV_CODEC_ID_RV20:
|
case AV_CODEC_ID_RV20:
|
||||||
break;
|
break;
|
||||||
|
#if CONFIG_H263I_DECODER
|
||||||
|
case AV_CODEC_ID_H263I:
|
||||||
|
h->decode_header = ff_intel_h263_decode_picture_header;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#if CONFIG_FLV_DECODER
|
||||||
case AV_CODEC_ID_FLV1:
|
case AV_CODEC_ID_FLV1:
|
||||||
s->h263_flv = 1;
|
s->h263_flv = 1;
|
||||||
|
h->decode_header = ff_flv_decode_picture_header;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
av_unreachable("Switch contains a case for every codec using ff_h263_decode_init()");
|
av_unreachable("Switch contains a case for every codec using ff_h263_decode_init()");
|
||||||
}
|
}
|
||||||
@ -461,22 +469,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
|
|||||||
bak_height = h->c.height;
|
bak_height = h->c.height;
|
||||||
|
|
||||||
/* let's go :-) */
|
/* let's go :-) */
|
||||||
if (CONFIG_WMV2_DECODER && h->c.msmpeg4_version == MSMP4_WMV2) {
|
ret = h->decode_header(h);
|
||||||
ret = ff_wmv2_decode_picture_header(h);
|
|
||||||
#if CONFIG_MSMPEG4DEC
|
|
||||||
} else if (h->c.msmpeg4_version != MSMP4_UNUSED) {
|
|
||||||
ret = ff_msmpeg4_decode_picture_header(h);
|
|
||||||
#endif
|
|
||||||
} else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
|
|
||||||
ret = ff_mpeg4_decode_picture_header(h);
|
|
||||||
} else if (CONFIG_H263I_DECODER && h->c.codec_id == AV_CODEC_ID_H263I) {
|
|
||||||
ret = ff_intel_h263_decode_picture_header(h);
|
|
||||||
} else if (CONFIG_FLV_DECODER && h->c.h263_flv) {
|
|
||||||
ret = ff_flv_decode_picture_header(h);
|
|
||||||
} else {
|
|
||||||
ret = ff_h263_decode_picture_header(h);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret < 0 || ret == FRAME_SKIPPED) {
|
if (ret < 0 || ret == FRAME_SKIPPED) {
|
||||||
if ( h->c.width != bak_width
|
if ( h->c.width != bak_width
|
||||||
|| h->c.height != bak_height) {
|
|| h->c.height != bak_height) {
|
||||||
|
@ -25,11 +25,6 @@
|
|||||||
#include "vlc.h"
|
#include "vlc.h"
|
||||||
#include "libavutil/mem_internal.h"
|
#include "libavutil/mem_internal.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* Return value for header parsers if frame is not coded.
|
|
||||||
* */
|
|
||||||
#define FRAME_SKIPPED 100
|
|
||||||
|
|
||||||
// The defines below define the number of bits that are read at once for
|
// The defines below define the number of bits that are read at once for
|
||||||
// reading vlc values. Changing these may improve speed and data cache needs
|
// reading vlc values. Changing these may improve speed and data cache needs
|
||||||
// be aware though that decreasing them may need the number of stages that is
|
// be aware though that decreasing them may need the number of stages that is
|
||||||
@ -72,6 +67,9 @@ typedef struct H263DecContext {
|
|||||||
int rv10_version; ///< RV10 version: 0 or 3
|
int rv10_version; ///< RV10 version: 0 or 3
|
||||||
int rv10_first_dc_coded[3];
|
int rv10_first_dc_coded[3];
|
||||||
|
|
||||||
|
int (*decode_header)(struct H263DecContext *const h);
|
||||||
|
#define FRAME_SKIPPED 100 ///< Frame is not coded
|
||||||
|
|
||||||
int (*decode_mb)(struct H263DecContext *h);
|
int (*decode_mb)(struct H263DecContext *h);
|
||||||
#define SLICE_OK 0
|
#define SLICE_OK 0
|
||||||
#define SLICE_ERROR -1
|
#define SLICE_ERROR -1
|
||||||
|
@ -3736,7 +3736,7 @@ end:
|
|||||||
return decode_vop_header(ctx, gb, parse_only);
|
return decode_vop_header(ctx, gb, parse_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_mpeg4_decode_picture_header(H263DecContext *const h)
|
static int mpeg4_decode_picture_header(H263DecContext *const h)
|
||||||
{
|
{
|
||||||
Mpeg4DecContext *const ctx = h263_to_mpeg4(h);
|
Mpeg4DecContext *const ctx = h263_to_mpeg4(h);
|
||||||
|
|
||||||
@ -4017,6 +4017,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
h->c.h263_pred = 1;
|
h->c.h263_pred = 1;
|
||||||
h->c.low_delay = 0; /* default, might be overridden in the vol header during header parsing */
|
h->c.low_delay = 0; /* default, might be overridden in the vol header during header parsing */
|
||||||
|
h->decode_header = mpeg4_decode_picture_header;
|
||||||
h->decode_mb = mpeg4_decode_mb;
|
h->decode_mb = mpeg4_decode_mb;
|
||||||
ctx->time_increment_bits = 4; /* default value for broken headers */
|
ctx->time_increment_bits = 4; /* default value for broken headers */
|
||||||
ctx->quant_precision = 5;
|
ctx->quant_precision = 5;
|
||||||
|
@ -109,7 +109,6 @@ typedef struct Mpeg4DecContext {
|
|||||||
int dct_precision;
|
int dct_precision;
|
||||||
} Mpeg4DecContext;
|
} Mpeg4DecContext;
|
||||||
|
|
||||||
int ff_mpeg4_decode_picture_header(H263DecContext *const h);
|
|
||||||
int ff_mpeg4_parse_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb,
|
int ff_mpeg4_parse_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb,
|
||||||
int header, int parse_only);
|
int header, int parse_only);
|
||||||
void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb,
|
void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb,
|
||||||
|
@ -360,7 +360,7 @@ static av_cold void msmpeg4_decode_init_static(void)
|
|||||||
ff_msmp4_vc1_vlcs_init_once();
|
ff_msmp4_vc1_vlcs_init_once();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_msmpeg4_decode_picture_header(H263DecContext *const h)
|
static int msmpeg4_decode_picture_header(H263DecContext *const h)
|
||||||
{
|
{
|
||||||
MSMP4DecContext *const ms = mpv_to_msmpeg4(h);
|
MSMP4DecContext *const ms = mpv_to_msmpeg4(h);
|
||||||
int code;
|
int code;
|
||||||
@ -445,7 +445,7 @@ int ff_msmpeg4_decode_picture_header(H263DecContext *const h)
|
|||||||
h->c.inter_intra_pred= 0;
|
h->c.inter_intra_pred= 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_unreachable("ff_msmpeg4_decode_picture_header() only used by MSMP4V1-3, WMV1");
|
av_unreachable("msmpeg4_decode_picture_header() only used by MSMP4V1-3, WMV1");
|
||||||
}
|
}
|
||||||
h->c.no_rounding = 1;
|
h->c.no_rounding = 1;
|
||||||
if (h->c.avctx->debug & FF_DEBUG_PICT_INFO)
|
if (h->c.avctx->debug & FF_DEBUG_PICT_INFO)
|
||||||
@ -498,7 +498,7 @@ int ff_msmpeg4_decode_picture_header(H263DecContext *const h)
|
|||||||
ms->bit_rate <= II_BITRATE;
|
ms->bit_rate <= II_BITRATE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_unreachable("ff_msmpeg4_decode_picture_header() only used by MSMP4V1-3, WMV1");
|
av_unreachable("msmpeg4_decode_picture_header() only used by MSMP4V1-3, WMV1");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h->c.avctx->debug&FF_DEBUG_PICT_INFO)
|
if (h->c.avctx->debug&FF_DEBUG_PICT_INFO)
|
||||||
@ -847,6 +847,8 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
|
|||||||
// We unquantize inter blocks as we parse them.
|
// We unquantize inter blocks as we parse them.
|
||||||
h->c.dct_unquantize_inter = NULL;
|
h->c.dct_unquantize_inter = NULL;
|
||||||
|
|
||||||
|
h->decode_header = msmpeg4_decode_picture_header;
|
||||||
|
|
||||||
ff_msmpeg4_common_init(&h->c);
|
ff_msmpeg4_common_init(&h->c);
|
||||||
|
|
||||||
switch (h->c.msmpeg4_version) {
|
switch (h->c.msmpeg4_version) {
|
||||||
|
@ -53,7 +53,6 @@ extern const VLCElem *ff_mb_non_intra_vlc[4];
|
|||||||
extern VLCElem ff_inter_intra_vlc[8];
|
extern VLCElem ff_inter_intra_vlc[8];
|
||||||
|
|
||||||
int ff_msmpeg4_decode_init(AVCodecContext *avctx);
|
int ff_msmpeg4_decode_init(AVCodecContext *avctx);
|
||||||
int ff_msmpeg4_decode_picture_header(H263DecContext *const h);
|
|
||||||
int ff_msmpeg4_decode_ext_header(H263DecContext *const h, int buf_size);
|
int ff_msmpeg4_decode_ext_header(H263DecContext *const h, int buf_size);
|
||||||
void ff_msmpeg4_decode_motion(MSMP4DecContext *ms, int *mx_ptr, int *my_ptr);
|
void ff_msmpeg4_decode_motion(MSMP4DecContext *ms, int *mx_ptr, int *my_ptr);
|
||||||
int ff_msmpeg4_decode_block(MSMP4DecContext *ms, int16_t * block,
|
int ff_msmpeg4_decode_block(MSMP4DecContext *ms, int16_t * block,
|
||||||
|
@ -201,7 +201,7 @@ static int decode_ext_header(WMV2DecContext *w)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_wmv2_decode_picture_header(H263DecContext *const h)
|
static int wmv2_decode_picture_header(H263DecContext *const h)
|
||||||
{
|
{
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
@ -574,6 +574,7 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx)
|
|||||||
if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
|
if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
h->decode_header = wmv2_decode_picture_header;
|
||||||
h->decode_mb = wmv2_decode_mb;
|
h->decode_mb = wmv2_decode_mb;
|
||||||
|
|
||||||
ff_wmv2_common_init(s);
|
ff_wmv2_common_init(s);
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "mpegvideo.h"
|
#include "mpegvideo.h"
|
||||||
struct H263DecContext;
|
struct H263DecContext;
|
||||||
|
|
||||||
int ff_wmv2_decode_picture_header(struct H263DecContext *const h);
|
|
||||||
int ff_wmv2_decode_secondary_picture_header(struct H263DecContext *const h);
|
int ff_wmv2_decode_secondary_picture_header(struct H263DecContext *const h);
|
||||||
void ff_wmv2_add_mb(MpegEncContext *s, int16_t block[6][64],
|
void ff_wmv2_add_mb(MpegEncContext *s, int16_t block[6][64],
|
||||||
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr);
|
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr);
|
||||||
|
Reference in New Issue
Block a user