History

avcodec/msmpeg4dec: Add MSMPEG4DecContext

This is in preparation for further commits.

Andreas Rheinhardt committed 1 year ago

Commit f733cfc1 parent 0a9f58a3 files · +26 −16Browse files

Unified · Split

3 files
  1. libavcodec/msmpeg4dec.c +4 −4
  2. libavcodec/msmpeg4dec.h +10 −0
  3. libavcodec/wmv2dec.c +12 −12
libavcodec/msmpeg4dec.c+4−4
@@ -845,7 +845,7 @@ const FFCodec ff_msmpeg4v1_decoder = { · 844 unmodified lines
845 CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 1"),845 CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 1"),
846 .p.type = AVMEDIA_TYPE_VIDEO,846 .p.type = AVMEDIA_TYPE_VIDEO,
847 .p.id = AV_CODEC_ID_MSMPEG4V1,847 .p.id = AV_CODEC_ID_MSMPEG4V1,
848 .priv_data_size = sizeof(MpegEncContext),848 .priv_data_size = sizeof(MSMP4DecContext),
849 .init = ff_msmpeg4_decode_init,849 .init = ff_msmpeg4_decode_init,
850 FF_CODEC_DECODE_CB(ff_h263_decode_frame),850 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
851 .close = ff_mpv_decode_close,851 .close = ff_mpv_decode_close,
@@ -860,7 +860,7 @@ const FFCodec ff_msmpeg4v2_decoder = { · 8 unmodified lines
860 CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 2"),860 CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 2"),
861 .p.type = AVMEDIA_TYPE_VIDEO,861 .p.type = AVMEDIA_TYPE_VIDEO,
862 .p.id = AV_CODEC_ID_MSMPEG4V2,862 .p.id = AV_CODEC_ID_MSMPEG4V2,
863 .priv_data_size = sizeof(MpegEncContext),863 .priv_data_size = sizeof(MSMP4DecContext),
864 .init = ff_msmpeg4_decode_init,864 .init = ff_msmpeg4_decode_init,
865 FF_CODEC_DECODE_CB(ff_h263_decode_frame),865 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
866 .close = ff_mpv_decode_close,866 .close = ff_mpv_decode_close,
@@ -875,7 +875,7 @@ const FFCodec ff_msmpeg4v3_decoder = { · 8 unmodified lines
875 CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 3"),875 CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 3"),
876 .p.type = AVMEDIA_TYPE_VIDEO,876 .p.type = AVMEDIA_TYPE_VIDEO,
877 .p.id = AV_CODEC_ID_MSMPEG4V3,877 .p.id = AV_CODEC_ID_MSMPEG4V3,
878 .priv_data_size = sizeof(MpegEncContext),878 .priv_data_size = sizeof(MSMP4DecContext),
879 .init = ff_msmpeg4_decode_init,879 .init = ff_msmpeg4_decode_init,
880 FF_CODEC_DECODE_CB(ff_h263_decode_frame),880 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
881 .close = ff_mpv_decode_close,881 .close = ff_mpv_decode_close,
@@ -890,7 +890,7 @@ const FFCodec ff_wmv1_decoder = { · 8 unmodified lines
890 CODEC_LONG_NAME("Windows Media Video 7"),890 CODEC_LONG_NAME("Windows Media Video 7"),
891 .p.type = AVMEDIA_TYPE_VIDEO,891 .p.type = AVMEDIA_TYPE_VIDEO,
892 .p.id = AV_CODEC_ID_WMV1,892 .p.id = AV_CODEC_ID_WMV1,
893 .priv_data_size = sizeof(MpegEncContext),893 .priv_data_size = sizeof(MSMP4DecContext),
894 .init = ff_msmpeg4_decode_init,894 .init = ff_msmpeg4_decode_init,
895 FF_CODEC_DECODE_CB(ff_h263_decode_frame),895 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
896 .close = ff_mpv_decode_close,896 .close = ff_mpv_decode_close,
libavcodec/msmpeg4dec.h+10−0
@@ -28,6 +28,16 @@ · 27 unmodified lines
28#define INTER_INTRA_VLC_BITS 328#define INTER_INTRA_VLC_BITS 3
29#define MB_NON_INTRA_VLC_BITS 929#define MB_NON_INTRA_VLC_BITS 9
30 30
31typedef struct MSMP4DecContext {
32 MpegEncContext m;
33} MSMP4DecContext;
34
35static inline MSMP4DecContext *mpv_to_msmpeg4(MpegEncContext *s)
36{
37 // Only legal because no MSMPEG-4 decoder uses slice-threading.
38 return (MSMP4DecContext*)s;
39}
40
31extern const VLCElem *ff_mb_non_intra_vlc[4];41extern const VLCElem *ff_mb_non_intra_vlc[4];
32extern VLCElem ff_inter_intra_vlc[8];42extern VLCElem ff_inter_intra_vlc[8];
33 43
libavcodec/wmv2dec.c+12−12
@@ -37,7 +37,7 @@ · 36 unmodified lines
37#include "wmv2dec.h"37#include "wmv2dec.h"
38 38
39typedef struct WMV2DecContext {39typedef struct WMV2DecContext {
40 MpegEncContext s;40 MSMP4DecContext ms;
41 WMV2Context common;41 WMV2Context common;
42 IntraX8Context x8;42 IntraX8Context x8;
43 int j_type_bit;43 int j_type_bit;
@@ -59,7 +59,7 @@ typedef struct WMV2DecContext { · 15 unmodified lines
59static void wmv2_add_block(WMV2DecContext *w, int16_t *block1,59static void wmv2_add_block(WMV2DecContext *w, int16_t *block1,
60 uint8_t *dst, int stride, int n)60 uint8_t *dst, int stride, int n)
61{61{
62 MpegEncContext *const s = &w->s;62 MpegEncContext *const s = &w->ms.m;
63 63
64 if (s->block_last_index[n] >= 0) {64 if (s->block_last_index[n] >= 0) {
65 switch (w->abt_type_table[n]) {65 switch (w->abt_type_table[n]) {
@@ -103,7 +103,7 @@ static int parse_mb_skip(WMV2DecContext *w) · 37 unmodified lines
103{103{
104 int mb_x, mb_y;104 int mb_x, mb_y;
105 int coded_mb_count = 0;105 int coded_mb_count = 0;
106 MpegEncContext *const s = &w->s;106 MpegEncContext *const s = &w->ms.m;
107 uint32_t *const mb_type = s->cur_pic.mb_type;107 uint32_t *const mb_type = s->cur_pic.mb_type;
108 108
109 w->skip_type = get_bits(&s->gb, 2);109 w->skip_type = get_bits(&s->gb, 2);
@@ -166,7 +166,7 @@ static int parse_mb_skip(WMV2DecContext *w) · 56 unmodified lines
166 166
167static int decode_ext_header(WMV2DecContext *w)167static int decode_ext_header(WMV2DecContext *w)
168{168{
169 MpegEncContext *const s = &w->s;169 MpegEncContext *const s = &w->ms.m;
170 GetBitContext gb;170 GetBitContext gb;
171 int fps;171 int fps;
172 int code;172 int code;
@@ -336,8 +336,8 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s) · 163 unmodified lines
336 2 * s->qscale, (s->qscale - 1) | 1,336 2 * s->qscale, (s->qscale - 1) | 1,
337 s->loop_filter, s->low_delay);337 s->loop_filter, s->low_delay);
338 338
339 ff_er_add_slice(&w->s.er, 0, 0,339 ff_er_add_slice(&s->er, 0, 0,
340 (w->s.mb_x >> 1) - 1, (w->s.mb_y >> 1) - 1,340 (s->mb_x >> 1) - 1, (s->mb_y >> 1) - 1,
341 ER_MB_END);341 ER_MB_END);
342 return 1;342 return 1;
343 }343 }
@@ -347,7 +347,7 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s) · 3 unmodified lines
347 347
348static inline void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_ptr)348static inline void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_ptr)
349{349{
350 MpegEncContext *const s = &w->s;350 MpegEncContext *const s = &w->ms.m;
351 351
352 ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);352 ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);
353 353
@@ -359,7 +359,7 @@ static inline void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_pt · 5 unmodified lines
359 359
360static int16_t *wmv2_pred_motion(WMV2DecContext *w, int *px, int *py)360static int16_t *wmv2_pred_motion(WMV2DecContext *w, int *px, int *py)
361{361{
362 MpegEncContext *const s = &w->s;362 MpegEncContext *const s = &w->ms.m;
363 int xy, wrap, diff, type;363 int xy, wrap, diff, type;
364 int16_t *A, *B, *C, *mot_val;364 int16_t *A, *B, *C, *mot_val;
365 365
@@ -405,7 +405,7 @@ static int16_t *wmv2_pred_motion(WMV2DecContext *w, int *px, int *py) · 39 unmodified lines
405static inline int wmv2_decode_inter_block(WMV2DecContext *w, int16_t *block,405static inline int wmv2_decode_inter_block(WMV2DecContext *w, int16_t *block,
406 int n, int cbp)406 int n, int cbp)
407{407{
408 MpegEncContext *const s = &w->s;408 MpegEncContext *const s = &w->ms.m;
409 static const int sub_cbp_table[3] = { 2, 3, 1 };409 static const int sub_cbp_table[3] = { 2, 3, 1 };
410 int sub_cbp, ret;410 int sub_cbp, ret;
411 411
@@ -561,7 +561,7 @@ static int wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 149 unmodified lines
561static av_cold int wmv2_decode_init(AVCodecContext *avctx)561static av_cold int wmv2_decode_init(AVCodecContext *avctx)
562{562{
563 WMV2DecContext *const w = avctx->priv_data;563 WMV2DecContext *const w = avctx->priv_data;
564 MpegEncContext *const s = &w->s;564 MpegEncContext *const s = &w->ms.m;
565 int ret;565 int ret;
566 566
567 s->private_ctx = &w->common;567 s->private_ctx = &w->common;
@@ -575,8 +575,8 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx) · 7 unmodified lines
575 575
576 decode_ext_header(w);576 decode_ext_header(w);
577 577
578 return ff_intrax8_common_init(avctx, &w->x8, w->s.block,578 return ff_intrax8_common_init(avctx, &w->x8, s->block,
579 w->s.mb_width, w->s.mb_height);579 s->mb_width, s->mb_height);
580}580}
581 581
582static av_cold int wmv2_decode_end(AVCodecContext *avctx)582static av_cold int wmv2_decode_end(AVCodecContext *avctx)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t