* qatar/master: (25 commits) rv40dsp x86: MMX/MMX2/3DNow/SSE2/SSSE3 implementations of MC ape: Use unsigned integer maths arm: dsputil: fix overreads in put/avg_pixels functions h264: K&R formatting cosmetics for header files (part II/II) h264: K&R formatting cosmetics for header files (part I/II) rtmp: Implement check bandwidth notification. rtmp: Support 'rtmp_swfurl', an option which specifies the URL of the SWF player. rtmp: Support 'rtmp_flashver', an option which overrides the version of the Flash plugin. rtmp: Support 'rtmp_tcurl', an option which overrides the URL of the target stream. cmdutils: Add fallback case to switch in check_stream_specifier(). sctp: be consistent with socket option level configure: Add _XOPEN_SOURCE=600 to Solaris preprocessor flags. vcr1enc: drop pointless empty encode_init() wrapper function vcr1: drop pointless write-only AVCodecContext member from VCR1Context vcr1: group encoder code together to save #ifdefs vcr1: cosmetics: K&R prettyprinting, typos, parentheses, dead code, comments mov: make one comment slightly more specific lavr: replace the SSE version of ff_conv_fltp_to_flt_6ch() with SSE4 and AVX lavfi: move audio-related functions to a separate file. lavfi: remove some audio-related function from public API. ... Conflicts: cmdutils.c libavcodec/h264.h libavcodec/h264_mvpred.h libavcodec/vcr1.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/defaults.c libavfilter/internal.h
Unified · Split
| @@ -38,6 +38,7 @@ · 37 unmodified lines | |||
| 38 | #if CONFIG_POSTPROC | 38 | #if CONFIG_POSTPROC |
| 39 | #include "libpostproc/postprocess.h" | 39 | #include "libpostproc/postprocess.h" |
| 40 | #endif | 40 | #endif |
| 41 | #include "libavutil/avassert.h" | ||
| 41 | #include "libavutil/avstring.h" | 42 | #include "libavutil/avstring.h" |
| 42 | #include "libavutil/mathematics.h" | 43 | #include "libavutil/mathematics.h" |
| 43 | #include "libavutil/parseutils.h" | 44 | #include "libavutil/parseutils.h" |
| @@ -1075,7 +1076,7 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) · 1031 unmodified lines | |||
| 1075 | case 's': type = AVMEDIA_TYPE_SUBTITLE; break; | 1076 | case 's': type = AVMEDIA_TYPE_SUBTITLE; break; |
| 1076 | case 'd': type = AVMEDIA_TYPE_DATA; break; | 1077 | case 'd': type = AVMEDIA_TYPE_DATA; break; |
| 1077 | case 't': type = AVMEDIA_TYPE_ATTACHMENT; break; | 1078 | case 't': type = AVMEDIA_TYPE_ATTACHMENT; break; |
| 1078 | default: abort(); // never reached, silence warning | 1079 | default: av_assert0(0); |
| 1079 | } | 1080 | } |
| 1080 | if (type != st->codec->codec_type) | 1081 | if (type != st->codec->codec_type) |
| 1081 | return 0; | 1082 | return 0; |
| @@ -2662,7 +2662,7 @@ case $target_os in · 2661 unmodified lines | |||
| 2662 | SHFLAGS='-shared -Wl,-h,$$(@F)' | 2662 | SHFLAGS='-shared -Wl,-h,$$(@F)' |
| 2663 | enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS" | 2663 | enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS" |
| 2664 | network_extralibs="-lsocket -lnsl" | 2664 | network_extralibs="-lsocket -lnsl" |
| 2665 | add_cppflags -D__EXTENSIONS__ | 2665 | add_cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 |
| 2666 | # When using suncc to build, the Solaris linker will mark | 2666 | # When using suncc to build, the Solaris linker will mark |
| 2667 | # an executable with each instruction set encountered by | 2667 | # an executable with each instruction set encountered by |
| 2668 | # the Solaris assembler. As our libraries contain their own | 2668 | # the Solaris assembler. As our libraries contain their own |
| @@ -393,7 +393,7 @@ static inline int range_get_symbol(APEContext *ctx, · 392 unmodified lines | |||
| 393 | } | 393 | } |
| 394 | /** @} */ // group rangecoder | 394 | /** @} */ // group rangecoder |
| 395 | 395 | ||
| 396 | static inline void update_rice(APERice *rice, int x) | 396 | static inline void update_rice(APERice *rice, unsigned int x) |
| 397 | { | 397 | { |
| 398 | int lim = rice->k ? (1 << (rice->k + 4)) : 0; | 398 | int lim = rice->k ? (1 << (rice->k + 4)) : 0; |
| 399 | rice->ksum += ((x + 1) / 2) - ((rice->ksum + 16) >> 5); | 399 | rice->ksum += ((x + 1) / 2) - ((rice->ksum + 16) >> 5); |
| @@ -406,7 +406,7 @@ static inline void update_rice(APERice *rice, int x) · 6 unmodified lines | |||
| 406 | 406 | ||
| 407 | static inline int ape_decode_value(APEContext *ctx, APERice *rice) | 407 | static inline int ape_decode_value(APEContext *ctx, APERice *rice) |
| 408 | { | 408 | { |
| 409 | int x, overflow; | 409 | unsigned int x, overflow; |
| 410 | 410 | ||
| 411 | if (ctx->fileversion < 3990) { | 411 | if (ctx->fileversion < 3990) { |
| 412 | int tmpk; | 412 | int tmpk; |
| @@ -95,6 +95,7 @@ endfunc · 94 unmodified lines | |||
| 95 | .endm | 95 | .endm |
| 96 | 96 | ||
| 97 | .macro pixels16_y2 rnd=1, avg=0 | 97 | .macro pixels16_y2 rnd=1, avg=0 |
| 98 | sub r3, r3, #2 | ||
| 98 | vld1.64 {q0}, [r1], r2 | 99 | vld1.64 {q0}, [r1], r2 |
| 99 | vld1.64 {q1}, [r1], r2 | 100 | vld1.64 {q1}, [r1], r2 |
| 100 | 1: subs r3, r3, #2 | 101 | 1: subs r3, r3, #2 |
| @@ -114,10 +115,25 @@ endfunc · 13 unmodified lines | |||
| 114 | vst1.64 {q2}, [r0,:128], r2 | 115 | vst1.64 {q2}, [r0,:128], r2 |
| 115 | vst1.64 {q3}, [r0,:128], r2 | 116 | vst1.64 {q3}, [r0,:128], r2 |
| 116 | bne 1b | 117 | bne 1b |
| 118 | |||
| 119 | avg q2, q0, q1 | ||
| 120 | vld1.64 {q0}, [r1], r2 | ||
| 121 | avg q3, q0, q1 | ||
| 122 | .if \avg | ||
| 123 | vld1.8 {q8}, [r0,:128], r2 | ||
| 124 | vld1.8 {q9}, [r0,:128] | ||
| 125 | vrhadd.u8 q2, q2, q8 | ||
| 126 | vrhadd.u8 q3, q3, q9 | ||
| 127 | sub r0, r0, r2 | ||
| 128 | .endif | ||
| 129 | vst1.64 {q2}, [r0,:128], r2 | ||
| 130 | vst1.64 {q3}, [r0,:128], r2 | ||
| 131 | |||
| 117 | bx lr | 132 | bx lr |
| 118 | .endm | 133 | .endm |
| 119 | 134 | ||
| 120 | .macro pixels16_xy2 rnd=1, avg=0 | 135 | .macro pixels16_xy2 rnd=1, avg=0 |
| 136 | sub r3, r3, #2 | ||
| 121 | vld1.64 {d0-d2}, [r1], r2 | 137 | vld1.64 {d0-d2}, [r1], r2 |
| 122 | vld1.64 {d4-d6}, [r1], r2 | 138 | vld1.64 {d4-d6}, [r1], r2 |
| 123 | .ifeq \rnd | 139 | .ifeq \rnd |
| @@ -173,6 +189,42 @@ endfunc · 49 unmodified lines | |||
| 173 | vaddl.u8 q11, d3, d5 | 189 | vaddl.u8 q11, d3, d5 |
| 174 | vst1.64 {q15}, [r0,:128], r2 | 190 | vst1.64 {q15}, [r0,:128], r2 |
| 175 | bgt 1b | 191 | bgt 1b |
| 192 | |||
| 193 | vld1.64 {d0-d2}, [r1], r2 | ||
| 194 | vadd.u16 q12, q8, q9 | ||
| 195 | .ifeq \rnd | ||
| 196 | vadd.u16 q12, q12, q13 | ||
| 197 | .endif | ||
| 198 | vext.8 q15, q0, q1, #1 | ||
| 199 | vadd.u16 q1 , q10, q11 | ||
| 200 | shrn d28, q12, #2 | ||
| 201 | .ifeq \rnd | ||
| 202 | vadd.u16 q1, q1, q13 | ||
| 203 | .endif | ||
| 204 | shrn d29, q1, #2 | ||
| 205 | .if \avg | ||
| 206 | vld1.8 {q8}, [r0,:128] | ||
| 207 | vrhadd.u8 q14, q14, q8 | ||
| 208 | .endif | ||
| 209 | vaddl.u8 q8, d0, d30 | ||
| 210 | vaddl.u8 q10, d1, d31 | ||
| 211 | vst1.64 {q14}, [r0,:128], r2 | ||
| 212 | vadd.u16 q12, q8, q9 | ||
| 213 | .ifeq \rnd | ||
| 214 | vadd.u16 q12, q12, q13 | ||
| 215 | .endif | ||
| 216 | vadd.u16 q0, q10, q11 | ||
| 217 | shrn d30, q12, #2 | ||
| 218 | .ifeq \rnd | ||
| 219 | vadd.u16 q0, q0, q13 | ||
| 220 | .endif | ||
| 221 | shrn d31, q0, #2 | ||
| 222 | .if \avg | ||
| 223 | vld1.8 {q9}, [r0,:128] | ||
| 224 | vrhadd.u8 q15, q15, q9 | ||
| 225 | .endif | ||
| 226 | vst1.64 {q15}, [r0,:128], r2 | ||
| 227 | |||
| 176 | bx lr | 228 | bx lr |
| 177 | .endm | 229 | .endm |
| 178 | 230 | ||
| @@ -228,6 +280,7 @@ endfunc · 49 unmodified lines | |||
| 228 | .endm | 280 | .endm |
| 229 | 281 | ||
| 230 | .macro pixels8_y2 rnd=1, avg=0 | 282 | .macro pixels8_y2 rnd=1, avg=0 |
| 283 | sub r3, r3, #2 | ||
| 231 | vld1.64 {d0}, [r1], r2 | 284 | vld1.64 {d0}, [r1], r2 |
| 232 | vld1.64 {d1}, [r1], r2 | 285 | vld1.64 {d1}, [r1], r2 |
| 233 | 1: subs r3, r3, #2 | 286 | 1: subs r3, r3, #2 |
| @@ -246,10 +299,24 @@ endfunc · 12 unmodified lines | |||
| 246 | vst1.64 {d4}, [r0,:64], r2 | 299 | vst1.64 {d4}, [r0,:64], r2 |
| 247 | vst1.64 {d5}, [r0,:64], r2 | 300 | vst1.64 {d5}, [r0,:64], r2 |
| 248 | bne 1b | 301 | bne 1b |
| 302 | |||
| 303 | avg d4, d0, d1 | ||
| 304 | vld1.64 {d0}, [r1], r2 | ||
| 305 | avg d5, d0, d1 | ||
| 306 | .if \avg | ||
| 307 | vld1.8 {d2}, [r0,:64], r2 | ||
| 308 | vld1.8 {d3}, [r0,:64] | ||
| 309 | vrhadd.u8 q2, q2, q1 | ||
| 310 | sub r0, r0, r2 | ||
| 311 | .endif | ||
| 312 | vst1.64 {d4}, [r0,:64], r2 | ||
| 313 | vst1.64 {d5}, [r0,:64], r2 | ||
| 314 | |||
| 249 | bx lr | 315 | bx lr |
| 250 | .endm | 316 | .endm |
| 251 | 317 | ||
| 252 | .macro pixels8_xy2 rnd=1, avg=0 | 318 | .macro pixels8_xy2 rnd=1, avg=0 |
| 319 | sub r3, r3, #2 | ||
| 253 | vld1.64 {q0}, [r1], r2 | 320 | vld1.64 {q0}, [r1], r2 |
| 254 | vld1.64 {q1}, [r1], r2 | 321 | vld1.64 {q1}, [r1], r2 |
| 255 | .ifeq \rnd | 322 | .ifeq \rnd |
| @@ -291,6 +358,31 @@ endfunc · 35 unmodified lines | |||
| 291 | vaddl.u8 q9, d2, d6 | 358 | vaddl.u8 q9, d2, d6 |
| 292 | vst1.64 {d7}, [r0,:64], r2 | 359 | vst1.64 {d7}, [r0,:64], r2 |
| 293 | bgt 1b | 360 | bgt 1b |
| 361 | |||
| 362 | vld1.64 {q0}, [r1], r2 | ||
| 363 | vadd.u16 q10, q8, q9 | ||
| 364 | vext.8 d4, d0, d1, #1 | ||
| 365 | .ifeq \rnd | ||
| 366 | vadd.u16 q10, q10, q11 | ||
| 367 | .endif | ||
| 368 | vaddl.u8 q8, d0, d4 | ||
| 369 | shrn d5, q10, #2 | ||
| 370 | vadd.u16 q10, q8, q9 | ||
| 371 | .if \avg | ||
| 372 | vld1.8 {d7}, [r0,:64] | ||
| 373 | vrhadd.u8 d5, d5, d7 | ||
| 374 | .endif | ||
| 375 | .ifeq \rnd | ||
| 376 | vadd.u16 q10, q10, q11 | ||
| 377 | .endif | ||
| 378 | vst1.64 {d5}, [r0,:64], r2 | ||
| 379 | shrn d7, q10, #2 | ||
| 380 | .if \avg | ||
| 381 | vld1.8 {d5}, [r0,:64] | ||
| 382 | vrhadd.u8 d7, d7, d5 | ||
| 383 | .endif | ||
| 384 | vst1.64 {d7}, [r0,:64], r2 | ||
| 385 | |||
| 294 | bx lr | 386 | bx lr |
| 295 | .endm | 387 | .endm |
| 296 | 388 | ||
| @@ -37,14 +37,14 @@ · 36 unmodified lines | |||
| 37 | #include "rectangle.h" | 37 | #include "rectangle.h" |
| 38 | 38 | ||
| 39 | #define interlaced_dct interlaced_dct_is_a_bad_name | 39 | #define interlaced_dct interlaced_dct_is_a_bad_name |
| 40 | #define mb_intra mb_intra_is_not_initialized_see_mb_type | 40 | #define mb_intra mb_intra_is_not_initialized_see_mb_type |
| 41 | 41 | ||
| 42 | #define MAX_SPS_COUNT 32 | 42 | #define MAX_SPS_COUNT 32 |
| 43 | #define MAX_PPS_COUNT 256 | 43 | #define MAX_PPS_COUNT 256 |
| 44 | 44 | ||
| 45 | #define MAX_MMCO_COUNT 66 | 45 | #define MAX_MMCO_COUNT 66 |
| 46 | 46 | ||
| 47 | #define MAX_DELAYED_PIC_COUNT 16 | 47 | #define MAX_DELAYED_PIC_COUNT 16 |
| 48 | 48 | ||
| 49 | #define MAX_MBPAIR_SIZE (256*1024) // a tighter bound could be calculated if someone cares about a few bytes | 49 | #define MAX_MBPAIR_SIZE (256*1024) // a tighter bound could be calculated if someone cares about a few bytes |
| 50 | 50 | ||
| @@ -61,25 +61,25 @@ · 10 unmodified lines | |||
| 61 | #define MAX_SLICES 16 | 61 | #define MAX_SLICES 16 |
| 62 | 62 | ||
| 63 | #ifdef ALLOW_INTERLACE | 63 | #ifdef ALLOW_INTERLACE |
| 64 | #define MB_MBAFF h->mb_mbaff | 64 | #define MB_MBAFF h->mb_mbaff |
| 65 | #define MB_FIELD h->mb_field_decoding_flag | 65 | #define MB_FIELD h->mb_field_decoding_flag |
| 66 | #define FRAME_MBAFF h->mb_aff_frame | 66 | #define FRAME_MBAFF h->mb_aff_frame |
| 67 | #define FIELD_PICTURE (s->picture_structure != PICT_FRAME) | 67 | #define FIELD_PICTURE (s->picture_structure != PICT_FRAME) |
| 68 | #define LEFT_MBS 2 | 68 | #define LEFT_MBS 2 |
| 69 | #define LTOP 0 | 69 | #define LTOP 0 |
| 70 | #define LBOT 1 | 70 | #define LBOT 1 |
| 71 | #define LEFT(i) (i) | 71 | #define LEFT(i) (i) |
| 72 | #else | 72 | #else |
| 73 | #define MB_MBAFF 0 | 73 | #define MB_MBAFF 0 |
| 74 | #define MB_FIELD 0 | 74 | #define MB_FIELD 0 |
| 75 | #define FRAME_MBAFF 0 | 75 | #define FRAME_MBAFF 0 |
| 76 | #define FIELD_PICTURE 0 | 76 | #define FIELD_PICTURE 0 |
| 77 | #undef IS_INTERLACED | 77 | #undef IS_INTERLACED |
| 78 | #define IS_INTERLACED(mb_type) 0 | 78 | #define IS_INTERLACED(mb_type) 0 |
| 79 | #define LEFT_MBS 1 | 79 | #define LEFT_MBS 1 |
| 80 | #define LTOP 0 | 80 | #define LTOP 0 |
| 81 | #define LBOT 0 | 81 | #define LBOT 0 |
| 82 | #define LEFT(i) 0 | 82 | #define LEFT(i) 0 |
| 83 | #endif | 83 | #endif |
| 84 | #define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF || FIELD_PICTURE) | 84 | #define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF || FIELD_PICTURE) |
| 85 | 85 | ||
| @@ -91,9 +91,9 @@ · 5 unmodified lines | |||
| 91 | #define CHROMA422 (h->sps.chroma_format_idc == 2) | 91 | #define CHROMA422 (h->sps.chroma_format_idc == 2) |
| 92 | #define CHROMA444 (h->sps.chroma_format_idc == 3) | 92 | #define CHROMA444 (h->sps.chroma_format_idc == 3) |
| 93 | 93 | ||
| 94 | #define EXTENDED_SAR 255 | 94 | #define EXTENDED_SAR 255 |
| 95 | 95 | ||
| 96 | #define MB_TYPE_REF0 MB_TYPE_ACPRED //dirty but it fits in 16 bit | 96 | #define MB_TYPE_REF0 MB_TYPE_ACPRED // dirty but it fits in 16 bit |
| 97 | #define MB_TYPE_8x8DCT 0x01000000 | 97 | #define MB_TYPE_8x8DCT 0x01000000 |
| 98 | #define IS_REF0(a) ((a) & MB_TYPE_REF0) | 98 | #define IS_REF0(a) ((a) & MB_TYPE_REF0) |
| 99 | #define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT) | 99 | #define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT) |
| @@ -108,7 +108,7 @@ · 8 unmodified lines | |||
| 108 | 108 | ||
| 109 | /* NAL unit types */ | 109 | /* NAL unit types */ |
| 110 | enum { | 110 | enum { |
| 111 | NAL_SLICE=1, | 111 | NAL_SLICE = 1, |
| 112 | NAL_DPA, | 112 | NAL_DPA, |
| 113 | NAL_DPB, | 113 | NAL_DPB, |
| 114 | NAL_DPC, | 114 | NAL_DPC, |
| @@ -121,17 +121,17 @@ enum { · 6 unmodified lines | |||
| 121 | NAL_END_STREAM, | 121 | NAL_END_STREAM, |
| 122 | NAL_FILLER_DATA, | 122 | NAL_FILLER_DATA, |
| 123 | NAL_SPS_EXT, | 123 | NAL_SPS_EXT, |
| 124 | NAL_AUXILIARY_SLICE=19 | 124 | NAL_AUXILIARY_SLICE = 19 |
| 125 | }; | 125 | }; |
| 126 | 126 | ||
| 127 | /** | 127 | /** |
| 128 | * SEI message types | 128 | * SEI message types |
| 129 | */ | 129 | */ |
| 130 | typedef enum { | 130 | typedef enum { |
| 131 | SEI_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1) | 131 | SEI_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1) |
| 132 | SEI_TYPE_PIC_TIMING = 1, ///< picture timing | 132 | SEI_TYPE_PIC_TIMING = 1, ///< picture timing |
| 133 | SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data | 133 | SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data |
| 134 | SEI_TYPE_RECOVERY_POINT = 6 ///< recovery point (frame # to decoder sync) | 134 | SEI_TYPE_RECOVERY_POINT = 6 ///< recovery point (frame # to decoder sync) |
| 135 | } SEI_Type; | 135 | } SEI_Type; |
| 136 | 136 | ||
| 137 | /** | 137 | /** |
| @@ -152,8 +152,7 @@ typedef enum { · 14 unmodified lines | |||
| 152 | /** | 152 | /** |
| 153 | * Sequence parameter set | 153 | * Sequence parameter set |
| 154 | */ | 154 | */ |
| 155 | typedef struct SPS{ | 155 | typedef struct SPS { |
| 156 | |||
| 157 | int profile_idc; | 156 | int profile_idc; |
| 158 | int level_idc; | 157 | int level_idc; |
| 159 | int chroma_format_idc; | 158 | int chroma_format_idc; |
| @@ -170,9 +169,9 @@ typedef struct SPS{ · 10 unmodified lines | |||
| 170 | int mb_width; ///< pic_width_in_mbs_minus1 + 1 | 169 | int mb_width; ///< pic_width_in_mbs_minus1 + 1 |
| 171 | int mb_height; ///< pic_height_in_map_units_minus1 + 1 | 170 | int mb_height; ///< pic_height_in_map_units_minus1 + 1 |
| 172 | int frame_mbs_only_flag; | 171 | int frame_mbs_only_flag; |
| 173 | int mb_aff; ///<mb_adaptive_frame_field_flag | 172 | int mb_aff; ///< mb_adaptive_frame_field_flag |
| 174 | int direct_8x8_inference_flag; | 173 | int direct_8x8_inference_flag; |
| 175 | int crop; ///< frame_cropping_flag | 174 | int crop; ///< frame_cropping_flag |
| 176 | unsigned int crop_left; ///< frame_cropping_rect_left_offset | 175 | unsigned int crop_left; ///< frame_cropping_rect_left_offset |
| 177 | unsigned int crop_right; ///< frame_cropping_rect_right_offset | 176 | unsigned int crop_right; ///< frame_cropping_rect_right_offset |
| 178 | unsigned int crop_top; ///< frame_cropping_rect_top_offset | 177 | unsigned int crop_top; ///< frame_cropping_rect_top_offset |
| @@ -189,7 +188,7 @@ typedef struct SPS{ · 10 unmodified lines | |||
| 189 | uint32_t num_units_in_tick; | 188 | uint32_t num_units_in_tick; |
| 190 | uint32_t time_scale; | 189 | uint32_t time_scale; |
| 191 | int fixed_frame_rate_flag; | 190 | int fixed_frame_rate_flag; |
| 192 | short offset_for_ref_frame[256]; //FIXME dyn aloc? | 191 | short offset_for_ref_frame[256]; // FIXME dyn aloc? |
| 193 | int bitstream_restriction_flag; | 192 | int bitstream_restriction_flag; |
| 194 | int num_reorder_frames; | 193 | int num_reorder_frames; |
| 195 | int scaling_matrix_present; | 194 | int scaling_matrix_present; |
| @@ -199,20 +198,20 @@ typedef struct SPS{ · 3 unmodified lines | |||
| 199 | int vcl_hrd_parameters_present_flag; | 198 | int vcl_hrd_parameters_present_flag; |
| 200 | int pic_struct_present_flag; | 199 | int pic_struct_present_flag; |
| 201 | int time_offset_length; | 200 | int time_offset_length; |
| 202 | int cpb_cnt; ///< See H.264 E.1.2 | 201 | int cpb_cnt; ///< See H.264 E.1.2 |
| 203 | int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 +1 | 202 | int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 + 1 |
| 204 | int cpb_removal_delay_length; ///< cpb_removal_delay_length_minus1 + 1 | 203 | int cpb_removal_delay_length; ///< cpb_removal_delay_length_minus1 + 1 |
| 205 | int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1 | 204 | int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1 |
| 206 | int bit_depth_luma; ///< bit_depth_luma_minus8 + 8 | 205 | int bit_depth_luma; ///< bit_depth_luma_minus8 + 8 |
| 207 | int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8 | 206 | int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8 |
| 208 | int residual_color_transform_flag; ///< residual_colour_transform_flag | 207 | int residual_color_transform_flag; ///< residual_colour_transform_flag |
| 209 | int constraint_set_flags; ///< constraint_set[0-3]_flag | 208 | int constraint_set_flags; ///< constraint_set[0-3]_flag |
| 210 | }SPS; | 209 | } SPS; |
| 211 | 210 | ||
| 212 | /** | 211 | /** |
| 213 | * Picture parameter set | 212 | * Picture parameter set |
| 214 | */ | 213 | */ |
| 215 | typedef struct PPS{ | 214 | typedef struct PPS { |
| 216 | unsigned int sps_id; | 215 | unsigned int sps_id; |
| 217 | int cabac; ///< entropy_coding_mode_flag | 216 | int cabac; ///< entropy_coding_mode_flag |
| 218 | int pic_order_present; ///< pic_order_present_flag | 217 | int pic_order_present; ///< pic_order_present_flag |
| @@ -225,20 +224,20 @@ typedef struct PPS{ · 6 unmodified lines | |||
| 225 | int init_qs; ///< pic_init_qs_minus26 + 26 | 224 | int init_qs; ///< pic_init_qs_minus26 + 26 |
| 226 | int chroma_qp_index_offset[2]; | 225 | int chroma_qp_index_offset[2]; |
| 227 | int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag | 226 | int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag |
| 228 | int constrained_intra_pred; ///< constrained_intra_pred_flag | 227 | int constrained_intra_pred; ///< constrained_intra_pred_flag |
| 229 | int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag | 228 | int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag |
| 230 | int transform_8x8_mode; ///< transform_8x8_mode_flag | 229 | int transform_8x8_mode; ///< transform_8x8_mode_flag |
| 231 | uint8_t scaling_matrix4[6][16]; | 230 | uint8_t scaling_matrix4[6][16]; |
| 232 | uint8_t scaling_matrix8[6][64]; | 231 | uint8_t scaling_matrix8[6][64]; |
| 233 | uint8_t chroma_qp_table[2][QP_MAX_NUM+1]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table | 232 | uint8_t chroma_qp_table[2][QP_MAX_NUM+1]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table |
| 234 | int chroma_qp_diff; | 233 | int chroma_qp_diff; |
| 235 | }PPS; | 234 | } PPS; |
| 236 | 235 | ||
| 237 | /** | 236 | /** |
| 238 | * Memory management control operation opcode. | 237 | * Memory management control operation opcode. |
| 239 | */ | 238 | */ |
| 240 | typedef enum MMCOOpcode{ | 239 | typedef enum MMCOOpcode { |
| 241 | MMCO_END=0, | 240 | MMCO_END = 0, |
| 242 | MMCO_SHORT2UNUSED, | 241 | MMCO_SHORT2UNUSED, |
| 243 | MMCO_LONG2UNUSED, | 242 | MMCO_LONG2UNUSED, |
| 244 | MMCO_SHORT2LONG, | 243 | MMCO_SHORT2LONG, |
| @@ -250,7 +249,7 @@ typedef enum MMCOOpcode{ · 5 unmodified lines | |||
| 250 | /** | 249 | /** |
| 251 | * Memory management control operation. | 250 | * Memory management control operation. |
| 252 | */ | 251 | */ |
| 253 | typedef struct MMCO{ | 252 | typedef struct MMCO { |
| 254 | MMCOOpcode opcode; | 253 | MMCOOpcode opcode; |
| 255 | int short_pic_num; ///< pic_num without wrapping (pic_num & max_pic_num) | 254 | int short_pic_num; ///< pic_num without wrapping (pic_num & max_pic_num) |
| 256 | int long_arg; ///< index, pic_num, or num long refs depending on opcode | 255 | int long_arg; ///< index, pic_num, or num long refs depending on opcode |
| @@ -259,18 +258,18 @@ typedef struct MMCO{ · 2 unmodified lines | |||
| 259 | /** | 258 | /** |
| 260 | * H264Context | 259 | * H264Context |
| 261 | */ | 260 | */ |
| 262 | typedef struct H264Context{ | 261 | typedef struct H264Context { |
| 263 | MpegEncContext s; | 262 | MpegEncContext s; |
| 264 | H264DSPContext h264dsp; | 263 | H264DSPContext h264dsp; |
| 265 | int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264 | 264 | int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264 |
| 266 | int chroma_qp[2]; //QPc | 265 | int chroma_qp[2]; // QPc |
| 267 | 266 | ||
| 268 | int qp_thresh; ///< QP threshold to skip loopfilter | 267 | int qp_thresh; ///< QP threshold to skip loopfilter |
| 269 | 268 | ||
| 270 | int prev_mb_skipped; | 269 | int prev_mb_skipped; |
| 271 | int next_mb_skipped; | 270 | int next_mb_skipped; |
| 272 | 271 | ||
| 273 | //prediction stuff | 272 | // prediction stuff |
| 274 | int chroma_pred_mode; | 273 | int chroma_pred_mode; |
| 275 | int intra16x16_pred_mode; | 274 | int intra16x16_pred_mode; |
| 276 | 275 | ||
| @@ -284,32 +283,32 @@ typedef struct H264Context{ · 7 unmodified lines | |||
| 284 | int topright_type; | 283 | int topright_type; |
| 285 | int left_type[LEFT_MBS]; | 284 | int left_type[LEFT_MBS]; |
| 286 | 285 | ||
| 287 | const uint8_t * left_block; | 286 | const uint8_t *left_block; |
| 288 | int topleft_partition; | 287 | int topleft_partition; |
| 289 | 288 | ||
| 290 | int8_t intra4x4_pred_mode_cache[5*8]; | 289 | int8_t intra4x4_pred_mode_cache[5 * 8]; |
| 291 | int8_t (*intra4x4_pred_mode); | 290 | int8_t(*intra4x4_pred_mode); |
| 292 | H264PredContext hpc; | 291 | H264PredContext hpc; |
| 293 | unsigned int topleft_samples_available; | 292 | unsigned int topleft_samples_available; |
| 294 | unsigned int top_samples_available; | 293 | unsigned int top_samples_available; |
| 295 | unsigned int topright_samples_available; | 294 | unsigned int topright_samples_available; |
| 296 | unsigned int left_samples_available; | 295 | unsigned int left_samples_available; |
| 297 | uint8_t (*top_borders[2])[(16*3)*2]; | 296 | uint8_t (*top_borders[2])[(16 * 3) * 2]; |
| 298 | 297 | ||
| 299 | /** | 298 | /** |
| 300 | * non zero coeff count cache. | 299 | * non zero coeff count cache. |
| 301 | * is 64 if not available. | 300 | * is 64 if not available. |
| 302 | */ | 301 | */ |
| 303 | DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15*8]; | 302 | DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15 * 8]; |
| 304 | 303 | ||
| 305 | uint8_t (*non_zero_count)[48]; | 304 | uint8_t (*non_zero_count)[48]; |
| 306 | 305 | ||
| 307 | /** | 306 | /** |
| 308 | * Motion vector cache. | 307 | * Motion vector cache. |
| 309 | */ | 308 | */ |
| 310 | DECLARE_ALIGNED(16, int16_t, mv_cache)[2][5*8][2]; | 309 | DECLARE_ALIGNED(16, int16_t, mv_cache)[2][5 * 8][2]; |
| 311 | DECLARE_ALIGNED(8, int8_t, ref_cache)[2][5*8]; | 310 | DECLARE_ALIGNED(8, int8_t, ref_cache)[2][5 * 8]; |
| 312 | #define LIST_NOT_USED -1 //FIXME rename? | 311 | #define LIST_NOT_USED -1 // FIXME rename? |
| 313 | #define PART_NOT_AVAILABLE -2 | 312 | #define PART_NOT_AVAILABLE -2 |
| 314 | 313 | ||
| 315 | /** | 314 | /** |
| @@ -321,13 +320,13 @@ typedef struct H264Context{ · 5 unmodified lines | |||
| 321 | * block_offset[ 0..23] for frame macroblocks | 320 | * block_offset[ 0..23] for frame macroblocks |
| 322 | * block_offset[24..47] for field macroblocks | 321 | * block_offset[24..47] for field macroblocks |
| 323 | */ | 322 | */ |
| 324 | int block_offset[2*(16*3)]; | 323 | int block_offset[2 * (16 * 3)]; |
| 325 | 324 | ||
| 326 | uint32_t *mb2b_xy; //FIXME are these 4 a good idea? | 325 | uint32_t *mb2b_xy; // FIXME are these 4 a good idea? |
| 327 | uint32_t *mb2br_xy; | 326 | uint32_t *mb2br_xy; |
| 328 | int b_stride; //FIXME use s->b4_stride | 327 | int b_stride; // FIXME use s->b4_stride |
| 329 | 328 | ||
| 330 | int mb_linesize; ///< may be equal to s->linesize or s->linesize*2, for mbaff | 329 | int mb_linesize; ///< may be equal to s->linesize or s->linesize * 2, for mbaff |
| 331 | int mb_uvlinesize; | 330 | int mb_uvlinesize; |
| 332 | 331 | ||
| 333 | int emu_edge_width; | 332 | int emu_edge_width; |
| @@ -338,32 +337,32 @@ typedef struct H264Context{ · 4 unmodified lines | |||
| 338 | /** | 337 | /** |
| 339 | * current pps | 338 | * current pps |
| 340 | */ | 339 | */ |
| 341 | PPS pps; //FIXME move to Picture perhaps? (->no) do we need that? | 340 | PPS pps; // FIXME move to Picture perhaps? (->no) do we need that? |
| 342 | 341 | ||
| 343 | uint32_t dequant4_buffer[6][QP_MAX_NUM+1][16]; //FIXME should these be moved down? | 342 | uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16]; // FIXME should these be moved down? |
| 344 | uint32_t dequant8_buffer[6][QP_MAX_NUM+1][64]; | 343 | uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64]; |
| 345 | uint32_t (*dequant4_coeff[6])[16]; | 344 | uint32_t(*dequant4_coeff[6])[16]; |
| 346 | uint32_t (*dequant8_coeff[6])[64]; | 345 | uint32_t(*dequant8_coeff[6])[64]; |
| 347 | 346 | ||
| 348 | int slice_num; | 347 | int slice_num; |
| 349 | uint16_t *slice_table; ///< slice_table_base + 2*mb_stride + 1 | 348 | uint16_t *slice_table; ///< slice_table_base + 2*mb_stride + 1 |
| 350 | int slice_type; | 349 | int slice_type; |
| 351 | int slice_type_nos; ///< S free slice type (SI/SP are remapped to I/P) | 350 | int slice_type_nos; ///< S free slice type (SI/SP are remapped to I/P) |
| 352 | int slice_type_fixed; | 351 | int slice_type_fixed; |
| 353 | 352 | ||
| 354 | //interlacing specific flags | 353 | // interlacing specific flags |
| 355 | int mb_aff_frame; | 354 | int mb_aff_frame; |
| 356 | int mb_field_decoding_flag; | 355 | int mb_field_decoding_flag; |
| 357 | int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag | 356 | int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag |
| 358 | 357 | ||
| 359 | DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4]; | 358 | DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4]; |
| 360 | 359 | ||
| 361 | //Weighted pred stuff | 360 | // Weighted pred stuff |
| 362 | int use_weight; | 361 | int use_weight; |
| 363 | int use_weight_chroma; | 362 | int use_weight_chroma; |
| 364 | int luma_log2_weight_denom; | 363 | int luma_log2_weight_denom; |
| 365 | int chroma_log2_weight_denom; | 364 | int chroma_log2_weight_denom; |
| 366 | //The following 2 can be changed to int8_t but that causes 10cpu cycles speedloss | 365 | // The following 2 can be changed to int8_t but that causes 10cpu cycles speedloss |
| 367 | int luma_weight[48][2][2]; | 366 | int luma_weight[48][2][2]; |
| 368 | int chroma_weight[48][2][2][2]; | 367 | int chroma_weight[48][2][2][2]; |
| 369 | int implicit_weight[48][48][2]; | 368 | int implicit_weight[48][48][2]; |
| @@ -373,48 +372,48 @@ typedef struct H264Context{ · 3 unmodified lines | |||
| 373 | int col_fieldoff; | 372 | int col_fieldoff; |
| 374 | int dist_scale_factor[16]; | 373 | int dist_scale_factor[16]; |
| 375 | int dist_scale_factor_field[2][32]; | 374 | int dist_scale_factor_field[2][32]; |
| 376 | int map_col_to_list0[2][16+32]; | 375 | int map_col_to_list0[2][16 + 32]; |
| 377 | int map_col_to_list0_field[2][2][16+32]; | 376 | int map_col_to_list0_field[2][2][16 + 32]; |
| 378 | 377 | ||
| 379 | /** | 378 | /** |
| 380 | * num_ref_idx_l0/1_active_minus1 + 1 | 379 | * num_ref_idx_l0/1_active_minus1 + 1 |
| 381 | */ | 380 | */ |
| 382 | uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type | 381 | unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode |
| 383 | unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode | ||
| 384 | unsigned int list_count; | 382 | unsigned int list_count; |
| 385 | Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs. | 383 | uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type |
| 386 | Reordered version of default_ref_list | 384 | Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs. |
| 387 | according to picture reordering in slice header */ | 385 | * Reordered version of default_ref_list |
| 388 | int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1 | 386 | * according to picture reordering in slice header */ |
| 387 | int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1 | ||
| 389 | 388 | ||
| 390 | //data partitioning | 389 | // data partitioning |
| 391 | GetBitContext intra_gb; | 390 | GetBitContext intra_gb; |
| 392 | GetBitContext inter_gb; | 391 | GetBitContext inter_gb; |
| 393 | GetBitContext *intra_gb_ptr; | 392 | GetBitContext *intra_gb_ptr; |
| 394 | GetBitContext *inter_gb_ptr; | 393 | GetBitContext *inter_gb_ptr; |
| 395 | 394 | ||
| 396 | DECLARE_ALIGNED(16, DCTELEM, mb)[16*48*2]; ///< as a dct coeffecient is int32_t in high depth, we need to reserve twice the space. | 395 | DECLARE_ALIGNED(16, DCTELEM, mb)[16 * 48 * 2]; ///< as a dct coeffecient is int32_t in high depth, we need to reserve twice the space. |
| 397 | DECLARE_ALIGNED(16, DCTELEM, mb_luma_dc)[3][16*2]; | 396 | DECLARE_ALIGNED(16, DCTELEM, mb_luma_dc)[3][16 * 2]; |
| 398 | DCTELEM mb_padding[256*2]; ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not too large or ensure that there is some unused stuff after mb | 397 | DCTELEM mb_padding[256 * 2]; ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not too large or ensure that there is some unused stuff after mb |
| 399 | 398 | ||
| 400 | /** | 399 | /** |
| 401 | * Cabac | 400 | * Cabac |
| 402 | */ | 401 | */ |
| 403 | CABACContext cabac; | 402 | CABACContext cabac; |
| 404 | uint8_t cabac_state[1024]; | 403 | uint8_t cabac_state[1024]; |
| 405 | 404 | ||
| 406 | /* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0,1,2), 0x0? luma_cbp */ | 405 | /* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0, 1, 2), 0x0? luma_cbp */ |
| 407 | uint16_t *cbp_table; | 406 | uint16_t *cbp_table; |
| 408 | int cbp; | 407 | int cbp; |
| 409 | int top_cbp; | 408 | int top_cbp; |
| 410 | int left_cbp; | 409 | int left_cbp; |
| 411 | /* chroma_pred_mode for i4x4 or i16x16, else 0 */ | 410 | /* chroma_pred_mode for i4x4 or i16x16, else 0 */ |
| 412 | uint8_t *chroma_pred_mode_table; | 411 | uint8_t *chroma_pred_mode_table; |
| 413 | int last_qscale_diff; | 412 | int last_qscale_diff; |
| 414 | uint8_t (*mvd_table[2])[2]; | 413 | uint8_t (*mvd_table[2])[2]; |
| 415 | DECLARE_ALIGNED(16, uint8_t, mvd_cache)[2][5*8][2]; | 414 | DECLARE_ALIGNED(16, uint8_t, mvd_cache)[2][5 * 8][2]; |
| 416 | uint8_t *direct_table; | 415 | uint8_t *direct_table; |
| 417 | uint8_t direct_cache[5*8]; | 416 | uint8_t direct_cache[5 * 8]; |
| 418 | 417 | ||
| 419 | uint8_t zigzag_scan[16]; | 418 | uint8_t zigzag_scan[16]; |
| 420 | uint8_t zigzag_scan8x8[64]; | 419 | uint8_t zigzag_scan8x8[64]; |
| @@ -435,13 +434,13 @@ typedef struct H264Context{ · 14 unmodified lines | |||
| 435 | 434 | ||
| 436 | int is_complex; | 435 | int is_complex; |
| 437 | 436 | ||
| 438 | //deblock | 437 | // deblock |
| 439 | int deblocking_filter; ///< disable_deblocking_filter_idc with 1<->0 | 438 | int deblocking_filter; ///< disable_deblocking_filter_idc with 1 <-> 0 |
| 440 | int slice_alpha_c0_offset; | 439 | int slice_alpha_c0_offset; |
| 441 | int slice_beta_offset; | 440 | int slice_beta_offset; |
| 442 | 441 | ||
| 443 | //============================================================= | 442 | // ============================================================= |
| 444 | //Things below are not used in the MB or more inner code | 443 | // Things below are not used in the MB or more inner code |
| 445 | 444 | ||
| 446 | int nal_ref_idc; | 445 | int nal_ref_idc; |
| 447 | int nal_unit_type; | 446 | int nal_unit_type; |
| @@ -451,37 +450,36 @@ typedef struct H264Context{ · 3 unmodified lines | |||
| 451 | /** | 450 | /** |
| 452 | * Used to parse AVC variant of h264 | 451 | * Used to parse AVC variant of h264 |
| 453 | */ | 452 | */ |
| 454 | int is_avc; ///< this flag is != 0 if codec is avc1 | 453 | int is_avc; ///< this flag is != 0 if codec is avc1 |
| 455 | int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4) | 454 | int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4) |
| 456 | int got_first; ///< this flag is != 0 if we've parsed a frame | 455 | int got_first; ///< this flag is != 0 if we've parsed a frame |
| 457 | 456 | ||
| 458 | SPS *sps_buffers[MAX_SPS_COUNT]; | 457 | SPS *sps_buffers[MAX_SPS_COUNT]; |
| 459 | PPS *pps_buffers[MAX_PPS_COUNT]; | 458 | PPS *pps_buffers[MAX_PPS_COUNT]; |
| 460 | 459 | ||
| 461 | int dequant_coeff_pps; ///< reinit tables when pps changes | 460 | int dequant_coeff_pps; ///< reinit tables when pps changes |
| 462 | 461 | ||
| 463 | uint16_t *slice_table_base; | 462 | uint16_t *slice_table_base; |
| 464 | 463 | ||
| 465 | 464 | // POC stuff | |
| 466 | //POC stuff | ||
| 467 | int poc_lsb; | 465 | int poc_lsb; |
| 468 | int poc_msb; | 466 | int poc_msb; |
| 469 | int delta_poc_bottom; | 467 | int delta_poc_bottom; |
| 470 | int delta_poc[2]; | 468 | int delta_poc[2]; |
| 471 | int frame_num; | 469 | int frame_num; |
| 472 | int prev_poc_msb; ///< poc_msb of the last reference pic for POC type 0 | 470 | int prev_poc_msb; ///< poc_msb of the last reference pic for POC type 0 |
| 473 | int prev_poc_lsb; ///< poc_lsb of the last reference pic for POC type 0 | 471 | int prev_poc_lsb; ///< poc_lsb of the last reference pic for POC type 0 |
| 474 | int frame_num_offset; ///< for POC type 2 | 472 | int frame_num_offset; ///< for POC type 2 |
| 475 | int prev_frame_num_offset; ///< for POC type 2 | 473 | int prev_frame_num_offset; ///< for POC type 2 |
| 476 | int prev_frame_num; ///< frame_num of the last pic for POC type 1/2 | 474 | int prev_frame_num; ///< frame_num of the last pic for POC type 1/2 |
| 477 | 475 | ||
| 478 | /** | 476 | /** |
| 479 | * frame_num for frames or 2*frame_num+1 for field pics. | 477 | * frame_num for frames or 2 * frame_num + 1 for field pics. |
| 480 | */ | 478 | */ |
| 481 | int curr_pic_num; | 479 | int curr_pic_num; |
| 482 | 480 | ||
| 483 | /** | 481 | /** |
| 484 | * max_frame_num or 2*max_frame_num for field pics. | 482 | * max_frame_num or 2 * max_frame_num for field pics. |
| 485 | */ | 483 | */ |
| 486 | int max_pic_num; | 484 | int max_pic_num; |
| 487 | 485 | ||
| @@ -490,7 +488,7 @@ typedef struct H264Context{ · 2 unmodified lines | |||
| 490 | Picture *short_ref[32]; | 488 | Picture *short_ref[32]; |
| 491 | Picture *long_ref[32]; | 489 | Picture *long_ref[32]; |
| 492 | Picture default_ref_list[2][32]; ///< base reference list for all slices of a coded picture | 490 | Picture default_ref_list[2][32]; ///< base reference list for all slices of a coded picture |
| 493 | Picture *delayed_pic[MAX_DELAYED_PIC_COUNT+2]; //FIXME size? | 491 | Picture *delayed_pic[MAX_DELAYED_PIC_COUNT + 2]; // FIXME size? |
| 494 | int last_pocs[MAX_DELAYED_PIC_COUNT]; | 492 | int last_pocs[MAX_DELAYED_PIC_COUNT]; |
| 495 | Picture *next_output_pic; | 493 | Picture *next_output_pic; |
| 496 | int outputed_poc; | 494 | int outputed_poc; |
| @@ -503,10 +501,10 @@ typedef struct H264Context{ · 6 unmodified lines | |||
| 503 | int mmco_index; | 501 | int mmco_index; |
| 504 | int mmco_reset; | 502 | int mmco_reset; |
| 505 | 503 | ||
| 506 | int long_ref_count; ///< number of actual long term references | 504 | int long_ref_count; ///< number of actual long term references |
| 507 | int short_ref_count; ///< number of actual short term references | 505 | int short_ref_count; ///< number of actual short term references |
| 508 | 506 | ||
| 509 | int cabac_init_idc; | 507 | int cabac_init_idc; |
| 510 | 508 | ||
| 511 | /** | 509 | /** |
| 512 | * @name Members for slice based multithreading | 510 | * @name Members for slice based multithreading |
| @@ -582,12 +580,12 @@ typedef struct H264Context{ · 69 unmodified lines | |||
| 582 | */ | 580 | */ |
| 583 | int recovery_frame; | 581 | int recovery_frame; |
| 584 | 582 | ||
| 585 | int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag | 583 | int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag |
| 586 | int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag | 584 | int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag |
| 587 | 585 | ||
| 588 | // Timestamp stuff | 586 | // Timestamp stuff |
| 589 | int sei_buffering_period_present; ///< Buffering period SEI flag | 587 | int sei_buffering_period_present; ///< Buffering period SEI flag |
| 590 | int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs | 588 | int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs |
| 591 | 589 | ||
| 592 | int cur_chroma_format_idc; | 590 | int cur_chroma_format_idc; |
| 593 | 591 | ||
| @@ -598,10 +596,9 @@ typedef struct H264Context{ · 4 unmodified lines | |||
| 598 | uint8_t parse_history[4]; | 596 | uint8_t parse_history[4]; |
| 599 | int parse_history_count; | 597 | int parse_history_count; |
| 600 | int parse_last_mb; | 598 | int parse_last_mb; |
| 601 | }H264Context; | 599 | } H264Context; |
| 602 | |||
| 603 | 600 | ||
| 604 | extern const uint8_t ff_h264_chroma_qp[5][QP_MAX_NUM+1]; ///< One chroma qp table for each possible bit depth (8-12). | 601 | extern const uint8_t ff_h264_chroma_qp[5][QP_MAX_NUM + 1]; ///< One chroma qp table for each possible bit depth (8-12). |
| 605 | extern const uint16_t ff_h264_mb_sizes[4]; | 602 | extern const uint16_t ff_h264_mb_sizes[4]; |
| 606 | 603 | ||
| 607 | /** | 604 | /** |
| @@ -628,13 +625,16 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length); · 20 unmodified lines | |||
| 628 | * Decode a network abstraction layer unit. | 625 | * Decode a network abstraction layer unit. |
| 629 | * @param consumed is the number of bytes used as input | 626 | * @param consumed is the number of bytes used as input |
| 630 | * @param length is the length of the array | 627 | * @param length is the length of the array |
| 631 | * @param dst_length is the number of decoded bytes FIXME here or a decode rbsp tailing? | 628 | * @param dst_length is the number of decoded bytes FIXME here |
| 629 | * or a decode rbsp tailing? | ||
| 632 | * @return decoded bytes, might be src+1 if no escapes | 630 | * @return decoded bytes, might be src+1 if no escapes |
| 633 | */ | 631 | */ |
| 634 | const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length); | 632 | const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, |
| 633 | int *dst_length, int *consumed, int length); | ||
| 635 | 634 | ||
| 636 | /** | 635 | /** |
| 637 | * Free any data that may have been allocated in the H264 context like SPS, PPS etc. | 636 | * Free any data that may have been allocated in the H264 context |
| 637 | * like SPS, PPS etc. | ||
| 638 | */ | 638 | */ |
| 639 | av_cold void ff_h264_free_context(H264Context *h); | 639 | av_cold void ff_h264_free_context(H264Context *h); |
| 640 | 640 | ||
| @@ -667,12 +667,16 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb); · 26 unmodified lines | |||
| 667 | 667 | ||
| 668 | void ff_generate_sliding_window_mmcos(H264Context *h); | 668 | void ff_generate_sliding_window_mmcos(H264Context *h); |
| 669 | 669 | ||
| 670 | |||
| 671 | /** | 670 | /** |
| 672 | * Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks. | 671 | * Check if the top & left blocks are available if needed & change the |
| 672 | * dc mode so it only uses the available blocks. | ||
| 673 | */ | 673 | */ |
| 674 | int ff_h264_check_intra4x4_pred_mode(H264Context *h); | 674 | int ff_h264_check_intra4x4_pred_mode(H264Context *h); |
| 675 | 675 | ||
| 676 | /** | ||
| 677 | * Check if the top & left blocks are available if needed & change the | ||
| 678 | * dc mode so it only uses the available blocks. | ||
| 679 | */ | ||
| 676 | int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma); | 680 | int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma); |
| 677 | 681 | ||
| 678 | void ff_h264_hl_decode_mb(H264Context *h); | 682 | void ff_h264_hl_decode_mb(H264Context *h); |
| @@ -683,24 +687,28 @@ av_cold void ff_h264_decode_init_vlc(void); · 4 unmodified lines | |||
| 683 | 687 | ||
| 684 | /** | 688 | /** |
| 685 | * Decode a macroblock | 689 | * Decode a macroblock |
| 686 | * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed | 690 | * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error |
| 687 | */ | 691 | */ |
| 688 | int ff_h264_decode_mb_cavlc(H264Context *h); | 692 | int ff_h264_decode_mb_cavlc(H264Context *h); |
| 689 | 693 | ||
| 690 | /** | 694 | /** |
| 691 | * Decode a CABAC coded macroblock | 695 | * Decode a CABAC coded macroblock |
| 692 | * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed | 696 | * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error |
| 693 | */ | 697 | */ |
| 694 | int ff_h264_decode_mb_cabac(H264Context *h); | 698 | int ff_h264_decode_mb_cabac(H264Context *h); |
| 695 | 699 | ||
| 696 | void ff_h264_init_cabac_states(H264Context *h); | 700 | void ff_h264_init_cabac_states(H264Context *h); |
| 697 | 701 | ||
| 698 | void ff_h264_direct_dist_scale_factor(H264Context * const h); | 702 | void ff_h264_direct_dist_scale_factor(H264Context *const h); |
| 699 | void ff_h264_direct_ref_list_init(H264Context * const h); | 703 | void ff_h264_direct_ref_list_init(H264Context *const h); |
| 700 | void ff_h264_pred_direct_motion(H264Context * const h, int *mb_type); | 704 | void ff_h264_pred_direct_motion(H264Context *const h, int *mb_type); |
| 701 | 705 | ||
| 702 | void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize); | 706 | void ff_h264_filter_mb_fast(H264Context *h, int mb_x, int mb_y, |
| 703 | void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize); | 707 | uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, |
| 708 | unsigned int linesize, unsigned int uvlinesize); | ||
| 709 | void ff_h264_filter_mb(H264Context *h, int mb_x, int mb_y, | ||
| 710 | uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, | ||
| 711 | unsigned int linesize, unsigned int uvlinesize); | ||
| 704 | 712 | ||
| 705 | /** | 713 | /** |
| 706 | * Reset SEI values at the beginning of the frame. | 714 | * Reset SEI values at the beginning of the frame. |
| @@ -709,16 +717,15 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint · 2 unmodified lines | |||
| 709 | */ | 717 | */ |
| 710 | void ff_h264_reset_sei(H264Context *h); | 718 | void ff_h264_reset_sei(H264Context *h); |
| 711 | 719 | ||
| 712 | |||
| 713 | /* | 720 | /* |
| 714 | o-o o-o | 721 | * o-o o-o |
| 715 | / / / | 722 | * / / / |
| 716 | o-o o-o | 723 | * o-o o-o |
| 717 | ,---' | 724 | * ,---' |
| 718 | o-o o-o | 725 | * o-o o-o |
| 719 | / / / | 726 | * / / / |
| 720 | o-o o-o | 727 | * o-o o-o |
| 721 | */ | 728 | */ |
| 722 | 729 | ||
| 723 | /* Scan8 organization: | 730 | /* Scan8 organization: |
| 724 | * 0 1 2 3 4 5 6 7 | 731 | * 0 1 2 3 4 5 6 7 |
| @@ -743,156 +750,173 @@ o-o o-o · 18 unmodified lines | |||
| 743 | #define LUMA_DC_BLOCK_INDEX 48 | 750 | #define LUMA_DC_BLOCK_INDEX 48 |
| 744 | #define CHROMA_DC_BLOCK_INDEX 49 | 751 | #define CHROMA_DC_BLOCK_INDEX 49 |
| 745 | 752 | ||
| 746 | //This table must be here because scan8[constant] must be known at compiletime | 753 | // This table must be here because scan8[constant] must be known at compiletime |
| 747 | static const uint8_t scan8[16*3 + 3]={ | 754 | static const uint8_t scan8[16 * 3 + 3] = { |
| 748 | 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8, | 755 | 4 + 1 * 8, 5 + 1 * 8, 4 + 2 * 8, 5 + 2 * 8, |
| 749 | 6+ 1*8, 7+ 1*8, 6+ 2*8, 7+ 2*8, | 756 | 6 + 1 * 8, 7 + 1 * 8, 6 + 2 * 8, 7 + 2 * 8, |
| 750 | 4+ 3*8, 5+ 3*8, 4+ 4*8, 5+ 4*8, | 757 | 4 + 3 * 8, 5 + 3 * 8, 4 + 4 * 8, 5 + 4 * 8, |
| 751 | 6+ 3*8, 7+ 3*8, 6+ 4*8, 7+ 4*8, | 758 | 6 + 3 * 8, 7 + 3 * 8, 6 + 4 * 8, 7 + 4 * 8, |
| 752 | 4+ 6*8, 5+ 6*8, 4+ 7*8, 5+ 7*8, | 759 | 4 + 6 * 8, 5 + 6 * 8, 4 + 7 * 8, 5 + 7 * 8, |
| 753 | 6+ 6*8, 7+ 6*8, 6+ 7*8, 7+ 7*8, | 760 | 6 + 6 * 8, 7 + 6 * 8, 6 + 7 * 8, 7 + 7 * 8, |
| 754 | 4+ 8*8, 5+ 8*8, 4+ 9*8, 5+ 9*8, | 761 | 4 + 8 * 8, 5 + 8 * 8, 4 + 9 * 8, 5 + 9 * 8, |
| 755 | 6+ 8*8, 7+ 8*8, 6+ 9*8, 7+ 9*8, | 762 | 6 + 8 * 8, 7 + 8 * 8, 6 + 9 * 8, 7 + 9 * 8, |
| 756 | 4+11*8, 5+11*8, 4+12*8, 5+12*8, | 763 | 4 + 11 * 8, 5 + 11 * 8, 4 + 12 * 8, 5 + 12 * 8, |
| 757 | 6+11*8, 7+11*8, 6+12*8, 7+12*8, | 764 | 6 + 11 * 8, 7 + 11 * 8, 6 + 12 * 8, 7 + 12 * 8, |
| 758 | 4+13*8, 5+13*8, 4+14*8, 5+14*8, | 765 | 4 + 13 * 8, 5 + 13 * 8, 4 + 14 * 8, 5 + 14 * 8, |
| 759 | 6+13*8, 7+13*8, 6+14*8, 7+14*8, | 766 | 6 + 13 * 8, 7 + 13 * 8, 6 + 14 * 8, 7 + 14 * 8, |
| 760 | 0+ 0*8, 0+ 5*8, 0+10*8 | 767 | 0 + 0 * 8, 0 + 5 * 8, 0 + 10 * 8 |
| 761 | }; | 768 | }; |
| 762 | 769 | ||
| 763 | static av_always_inline uint32_t pack16to32(int a, int b){ | 770 | static av_always_inline uint32_t pack16to32(int a, int b) |
| 771 | { | ||
| 764 | #if HAVE_BIGENDIAN | 772 | #if HAVE_BIGENDIAN |
| 765 | return (b&0xFFFF) + (a<<16); | 773 | return (b & 0xFFFF) + (a << 16); |
| 766 | #else | 774 | #else |
| 767 | return (a&0xFFFF) + (b<<16); | 775 | return (a & 0xFFFF) + (b << 16); |
| 768 | #endif | 776 | #endif |
| 769 | } | 777 | } |
| 770 | 778 | ||
| 771 | static av_always_inline uint16_t pack8to16(int a, int b){ | 779 | static av_always_inline uint16_t pack8to16(int a, int b) |
| 780 | { | ||
| 772 | #if HAVE_BIGENDIAN | 781 | #if HAVE_BIGENDIAN |
| 773 | return (b&0xFF) + (a<<8); | 782 | return (b & 0xFF) + (a << 8); |
| 774 | #else | 783 | #else |
| 775 | return (a&0xFF) + (b<<8); | 784 | return (a & 0xFF) + (b << 8); |
| 776 | #endif | 785 | #endif |
| 777 | } | 786 | } |
| 778 | 787 | ||
| 779 | /** | 788 | /** |
| 780 | * Get the chroma qp. | 789 | * Get the chroma qp. |
| 781 | */ | 790 | */ |
| 782 | static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale){ | 791 | static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale) |
| 792 | { | ||
| 783 | return h->pps.chroma_qp_table[t][qscale]; | 793 | return h->pps.chroma_qp_table[t][qscale]; |
| 784 | } | 794 | } |
| 785 | 795 | ||
| 786 | /** | 796 | /** |
| 787 | * Get the predicted intra4x4 prediction mode. | 797 | * Get the predicted intra4x4 prediction mode. |
| 788 | */ | 798 | */ |
| 789 | static av_always_inline int pred_intra_mode(H264Context *h, int n){ | 799 | static av_always_inline int pred_intra_mode(H264Context *h, int n) |
| 790 | const int index8= scan8[n]; | 800 | { |
| 791 | const int left= h->intra4x4_pred_mode_cache[index8 - 1]; | 801 | const int index8 = scan8[n]; |
| 792 | const int top = h->intra4x4_pred_mode_cache[index8 - 8]; | 802 | const int left = h->intra4x4_pred_mode_cache[index8 - 1]; |
| 793 | const int min= FFMIN(left, top); | 803 | const int top = h->intra4x4_pred_mode_cache[index8 - 8]; |
| 804 | const int min = FFMIN(left, top); | ||
| 794 | 805 | ||
| 795 | tprintf(h->s.avctx, "mode:%d %d min:%d\n", left ,top, min); | 806 | tprintf(h->s.avctx, "mode:%d %d min:%d\n", left, top, min); |
| 796 | 807 | ||
| 797 | if(min<0) return DC_PRED; | 808 | if (min < 0) |
| 798 | else return min; | 809 | return DC_PRED; |
| 810 | else | ||
| 811 | return min; | ||
| 799 | } | 812 | } |
| 800 | 813 | ||
| 801 | static av_always_inline void write_back_intra_pred_mode(H264Context *h){ | 814 | static av_always_inline void write_back_intra_pred_mode(H264Context *h) |
| 802 | int8_t *i4x4= h->intra4x4_pred_mode + h->mb2br_xy[h->mb_xy]; | 815 | { |
| 803 | int8_t *i4x4_cache= h->intra4x4_pred_mode_cache; | 816 | int8_t *i4x4 = h->intra4x4_pred_mode + h->mb2br_xy[h->mb_xy]; |
| 817 | int8_t *i4x4_cache = h->intra4x4_pred_mode_cache; | ||
| 804 | 818 | ||
| 805 | AV_COPY32(i4x4, i4x4_cache + 4 + 8*4); | 819 | AV_COPY32(i4x4, i4x4_cache + 4 + 8 * 4); |
| 806 | i4x4[4]= i4x4_cache[7+8*3]; | 820 | i4x4[4] = i4x4_cache[7 + 8 * 3]; |
| 807 | i4x4[5]= i4x4_cache[7+8*2]; | 821 | i4x4[5] = i4x4_cache[7 + 8 * 2]; |
| 808 | i4x4[6]= i4x4_cache[7+8*1]; | 822 | i4x4[6] = i4x4_cache[7 + 8 * 1]; |
| 809 | } | 823 | } |
| 810 | 824 | ||
| 811 | static av_always_inline void write_back_non_zero_count(H264Context *h){ | 825 | static av_always_inline void write_back_non_zero_count(H264Context *h) |
| 812 | const int mb_xy= h->mb_xy; | 826 | { |
| 813 | uint8_t *nnz = h->non_zero_count[mb_xy]; | 827 | const int mb_xy = h->mb_xy; |
| 828 | uint8_t *nnz = h->non_zero_count[mb_xy]; | ||
| 814 | uint8_t *nnz_cache = h->non_zero_count_cache; | 829 | uint8_t *nnz_cache = h->non_zero_count_cache; |
| 815 | 830 | ||
| 816 | AV_COPY32(&nnz[ 0], &nnz_cache[4+8* 1]); | 831 | AV_COPY32(&nnz[ 0], &nnz_cache[4 + 8 * 1]); |
| 817 | AV_COPY32(&nnz[ 4], &nnz_cache[4+8* 2]); | 832 | AV_COPY32(&nnz[ 4], &nnz_cache[4 + 8 * 2]); |
| 818 | AV_COPY32(&nnz[ 8], &nnz_cache[4+8* 3]); | 833 | AV_COPY32(&nnz[ 8], &nnz_cache[4 + 8 * 3]); |
| 819 | AV_COPY32(&nnz[12], &nnz_cache[4+8* 4]); | 834 | AV_COPY32(&nnz[12], &nnz_cache[4 + 8 * 4]); |
| 820 | AV_COPY32(&nnz[16], &nnz_cache[4+8* 6]); | 835 | AV_COPY32(&nnz[16], &nnz_cache[4 + 8 * 6]); |
| 821 | AV_COPY32(&nnz[20], &nnz_cache[4+8* 7]); | 836 | AV_COPY32(&nnz[20], &nnz_cache[4 + 8 * 7]); |
| 822 | AV_COPY32(&nnz[32], &nnz_cache[4+8*11]); | 837 | AV_COPY32(&nnz[32], &nnz_cache[4 + 8 * 11]); |
| 823 | AV_COPY32(&nnz[36], &nnz_cache[4+8*12]); | 838 | AV_COPY32(&nnz[36], &nnz_cache[4 + 8 * 12]); |
| 824 | 839 | ||
| 825 | if(!h->s.chroma_y_shift){ | 840 | if (!h->s.chroma_y_shift) { |
| 826 | AV_COPY32(&nnz[24], &nnz_cache[4+8* 8]); | 841 | AV_COPY32(&nnz[24], &nnz_cache[4 + 8 * 8]); |
| 827 | AV_COPY32(&nnz[28], &nnz_cache[4+8* 9]); | 842 | AV_COPY32(&nnz[28], &nnz_cache[4 + 8 * 9]); |
| 828 | AV_COPY32(&nnz[40], &nnz_cache[4+8*13]); | 843 | AV_COPY32(&nnz[40], &nnz_cache[4 + 8 * 13]); |
| 829 | AV_COPY32(&nnz[44], &nnz_cache[4+8*14]); | 844 | AV_COPY32(&nnz[44], &nnz_cache[4 + 8 * 14]); |
| 830 | } | 845 | } |
| 831 | } | 846 | } |
| 832 | 847 | ||
| 833 | static av_always_inline void write_back_motion_list(H264Context *h, MpegEncContext * const s, int b_stride, | 848 | static av_always_inline void write_back_motion_list(H264Context *h, |
| 834 | int b_xy, int b8_xy, int mb_type, int list ) | 849 | MpegEncContext *const s, |
| 850 | int b_stride, | ||
| 851 | int b_xy, int b8_xy, | ||
| 852 | int mb_type, int list) | ||
| 835 | { | 853 | { |
| 836 | int16_t (*mv_dst)[2] = &s->current_picture.f.motion_val[list][b_xy]; | 854 | int16_t(*mv_dst)[2] = &s->current_picture.f.motion_val[list][b_xy]; |
| 837 | int16_t (*mv_src)[2] = &h->mv_cache[list][scan8[0]]; | 855 | int16_t(*mv_src)[2] = &h->mv_cache[list][scan8[0]]; |
| 838 | AV_COPY128(mv_dst + 0*b_stride, mv_src + 8*0); | 856 | AV_COPY128(mv_dst + 0 * b_stride, mv_src + 8 * 0); |
| 839 | AV_COPY128(mv_dst + 1*b_stride, mv_src + 8*1); | 857 | AV_COPY128(mv_dst + 1 * b_stride, mv_src + 8 * 1); |
| 840 | AV_COPY128(mv_dst + 2*b_stride, mv_src + 8*2); | 858 | AV_COPY128(mv_dst + 2 * b_stride, mv_src + 8 * 2); |
| 841 | AV_COPY128(mv_dst + 3*b_stride, mv_src + 8*3); | 859 | AV_COPY128(mv_dst + 3 * b_stride, mv_src + 8 * 3); |
| 842 | if( CABAC ) { | 860 | if (CABAC) { |
| 843 | uint8_t (*mvd_dst)[2] = &h->mvd_table[list][FMO ? 8*h->mb_xy : h->mb2br_xy[h->mb_xy]]; | 861 | uint8_t (*mvd_dst)[2] = &h->mvd_table[list][FMO ? 8 * h->mb_xy |
| 844 | uint8_t (*mvd_src)[2] = &h->mvd_cache[list][scan8[0]]; | 862 | : h->mb2br_xy[h->mb_xy]]; |
| 845 | if(IS_SKIP(mb_type)) | 863 | uint8_t(*mvd_src)[2] = &h->mvd_cache[list][scan8[0]]; |
| 864 | if (IS_SKIP(mb_type)) { | ||
| 846 | AV_ZERO128(mvd_dst); | 865 | AV_ZERO128(mvd_dst); |
| 847 | else{ | 866 | } else { |
| 848 | AV_COPY64(mvd_dst, mvd_src + 8*3); | 867 | AV_COPY64(mvd_dst, mvd_src + 8 * 3); |
| 849 | AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8*0); | 868 | AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8 * 0); |
| 850 | AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8*1); | 869 | AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8 * 1); |
| 851 | AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8*2); | 870 | AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8 * 2); |
| 852 | } | 871 | } |
| 853 | } | 872 | } |
| 854 | 873 | ||
| 855 | { | 874 | { |
| 856 | int8_t *ref_index = &s->current_picture.f.ref_index[list][b8_xy]; | 875 | int8_t *ref_index = &s->current_picture.f.ref_index[list][b8_xy]; |
| 857 | int8_t *ref_cache = h->ref_cache[list]; | 876 | int8_t *ref_cache = h->ref_cache[list]; |
| 858 | ref_index[0+0*2]= ref_cache[scan8[0]]; | 877 | ref_index[0 + 0 * 2] = ref_cache[scan8[0]]; |
| 859 | ref_index[1+0*2]= ref_cache[scan8[4]]; | 878 | ref_index[1 + 0 * 2] = ref_cache[scan8[4]]; |
| 860 | ref_index[0+1*2]= ref_cache[scan8[8]]; | 879 | ref_index[0 + 1 * 2] = ref_cache[scan8[8]]; |
| 861 | ref_index[1+1*2]= ref_cache[scan8[12]]; | 880 | ref_index[1 + 1 * 2] = ref_cache[scan8[12]]; |
| 862 | } | 881 | } |
| 863 | } | 882 | } |
| 864 | 883 | ||
| 865 | static av_always_inline void write_back_motion(H264Context *h, int mb_type){ | 884 | static av_always_inline void write_back_motion(H264Context *h, int mb_type) |
| 866 | MpegEncContext * const s = &h->s; | 885 | { |
| 867 | const int b_stride = h->b_stride; | 886 | MpegEncContext *const s = &h->s; |
| 868 | const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride; //try mb2b(8)_xy | 887 | const int b_stride = h->b_stride; |
| 869 | const int b8_xy= 4*h->mb_xy; | 888 | const int b_xy = 4 * s->mb_x + 4 * s->mb_y * h->b_stride; // try mb2b(8)_xy |
| 889 | const int b8_xy = 4 * h->mb_xy; | ||
| 870 | 890 | ||
| 871 | if(USES_LIST(mb_type, 0)){ | 891 | if (USES_LIST(mb_type, 0)) { |
| 872 | write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0); | 892 | write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0); |
| 873 | }else{ | 893 | } else { |
| 874 | fill_rectangle(&s->current_picture.f.ref_index[0][b8_xy], | 894 | fill_rectangle(&s->current_picture.f.ref_index[0][b8_xy], |
| 875 | 2, 2, 2, (uint8_t)LIST_NOT_USED, 1); | 895 | 2, 2, 2, (uint8_t)LIST_NOT_USED, 1); |
| 876 | } | 896 | } |
| 877 | if(USES_LIST(mb_type, 1)){ | 897 | if (USES_LIST(mb_type, 1)) |
| 878 | write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 1); | 898 | write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 1); |
| 879 | } | ||
| 880 | 899 | ||
| 881 | if(h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC){ | 900 | if (h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC) { |
| 882 | if(IS_8X8(mb_type)){ | 901 | if (IS_8X8(mb_type)) { |
| 883 | uint8_t *direct_table = &h->direct_table[4*h->mb_xy]; | 902 | uint8_t *direct_table = &h->direct_table[4 * h->mb_xy]; |
| 884 | direct_table[1] = h->sub_mb_type[1]>>1; | 903 | direct_table[1] = h->sub_mb_type[1] >> 1; |
| 885 | direct_table[2] = h->sub_mb_type[2]>>1; | 904 | direct_table[2] = h->sub_mb_type[2] >> 1; |
| 886 | direct_table[3] = h->sub_mb_type[3]>>1; | 905 | direct_table[3] = h->sub_mb_type[3] >> 1; |
| 887 | } | 906 | } |
| 888 | } | 907 | } |
| 889 | } | 908 | } |
| 890 | 909 | ||
| 891 | static av_always_inline int get_dct8x8_allowed(H264Context *h){ | 910 | static av_always_inline int get_dct8x8_allowed(H264Context *h) |
| 892 | if(h->sps.direct_8x8_inference_flag) | 911 | { |
| 893 | return !(AV_RN64A(h->sub_mb_type) & ((MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8 )*0x0001000100010001ULL)); | 912 | if (h->sps.direct_8x8_inference_flag) |
| 913 | return !(AV_RN64A(h->sub_mb_type) & | ||
| 914 | ((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8) * | ||
| 915 | 0x0001000100010001ULL)); | ||
| 894 | else | 916 | else |
| 895 | return !(AV_RN64A(h->sub_mb_type) & ((MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8|MB_TYPE_DIRECT2)*0x0001000100010001ULL)); | 917 | return !(AV_RN64A(h->sub_mb_type) & |
| 918 | ((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8 | MB_TYPE_DIRECT2) * | ||
| 919 | 0x0001000100010001ULL)); | ||
| 896 | } | 920 | } |
| 897 | 921 | ||
| 898 | #endif /* AVCODEC_H264_H */ | 922 | #endif /* AVCODEC_H264_H */ |
| @@ -35,53 +35,53 @@ · 34 unmodified lines | |||
| 35 | //#undef NDEBUG | 35 | //#undef NDEBUG |
| 36 | #include <assert.h> | 36 | #include <assert.h> |
| 37 | 37 | ||
| 38 | static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, int list, int part_width){ | 38 | static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, |
| 39 | const int topright_ref= h->ref_cache[list][ i - 8 + part_width ]; | 39 | int i, int list, int part_width) |
| 40 | MpegEncContext *s = &h->s; | 40 | { |
| 41 | const int topright_ref = h->ref_cache[list][i - 8 + part_width]; | ||
| 42 | MpegEncContext *s = &h->s; | ||
| 41 | 43 | ||
| 42 | /* there is no consistent mapping of mvs to neighboring locations that will | 44 | /* there is no consistent mapping of mvs to neighboring locations that will |
| 43 | * make mbaff happy, so we can't move all this logic to fill_caches */ | 45 | * make mbaff happy, so we can't move all this logic to fill_caches */ |
| 44 | if(FRAME_MBAFF){ | 46 | if (FRAME_MBAFF) { |
| 45 | 47 | #define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4) \ | |
| 46 | #define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4)\ | 48 | const int xy = XY, y4 = Y4; \ |
| 47 | const int xy = XY, y4 = Y4;\ | 49 | const int mb_type = mb_types[xy + (y4 >> 2) * s->mb_stride]; \ |
| 48 | const int mb_type = mb_types[xy+(y4>>2)*s->mb_stride];\ | 50 | if (!USES_LIST(mb_type, list)) \ |
| 49 | if(!USES_LIST(mb_type,list))\ | 51 | return LIST_NOT_USED; \ |
| 50 | return LIST_NOT_USED;\ | 52 | mv = s->current_picture_ptr->f.motion_val[list][h->mb2b_xy[xy] + 3 + y4 * h->b_stride]; \ |
| 51 | mv = s->current_picture_ptr->f.motion_val[list][h->mb2b_xy[xy] + 3 + y4*h->b_stride];\ | 53 | h->mv_cache[list][scan8[0] - 2][0] = mv[0]; \ |
| 52 | h->mv_cache[list][scan8[0]-2][0] = mv[0];\ | 54 | h->mv_cache[list][scan8[0] - 2][1] = mv[1] MV_OP; \ |
| 53 | h->mv_cache[list][scan8[0]-2][1] = mv[1] MV_OP;\ | 55 | return s->current_picture_ptr->f.ref_index[list][4 * xy + 1 + (y4 & ~1)] REF_OP; |
| 54 | return s->current_picture_ptr->f.ref_index[list][4*xy + 1 + (y4 & ~1)] REF_OP; | 56 | |
| 55 | 57 | if (topright_ref == PART_NOT_AVAILABLE | |
| 56 | if(topright_ref == PART_NOT_AVAILABLE | 58 | && i >= scan8[0] + 8 && (i & 7) == 4 |
| 57 | && i >= scan8[0]+8 && (i&7)==4 | 59 | && h->ref_cache[list][scan8[0] - 1] != PART_NOT_AVAILABLE) { |
| 58 | && h->ref_cache[list][scan8[0]-1] != PART_NOT_AVAILABLE){ | ||
| 59 | const uint32_t *mb_types = s->current_picture_ptr->f.mb_type; | 60 | const uint32_t *mb_types = s->current_picture_ptr->f.mb_type; |
| 60 | const int16_t *mv; | 61 | const int16_t *mv; |
| 61 | AV_ZERO32(h->mv_cache[list][scan8[0]-2]); | 62 | AV_ZERO32(h->mv_cache[list][scan8[0] - 2]); |
| 62 | *C = h->mv_cache[list][scan8[0]-2]; | 63 | *C = h->mv_cache[list][scan8[0] - 2]; |
| 63 | 64 | ||
| 64 | if(!MB_FIELD | 65 | if (!MB_FIELD && IS_INTERLACED(h->left_type[0])) { |
| 65 | && IS_INTERLACED(h->left_type[0])){ | 66 | SET_DIAG_MV(* 2, >> 1, h->left_mb_xy[0] + s->mb_stride, |
| 66 | SET_DIAG_MV(*2, >>1, h->left_mb_xy[0]+s->mb_stride, (s->mb_y&1)*2+(i>>5)); | 67 | (s->mb_y & 1) * 2 + (i >> 5)); |
| 67 | } | 68 | } |
| 68 | if(MB_FIELD | 69 | if (MB_FIELD && !IS_INTERLACED(h->left_type[0])) { |
| 69 | && !IS_INTERLACED(h->left_type[0])){ | ||
| 70 | // left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK. | 70 | // left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK. |
| 71 | SET_DIAG_MV(/2, <<1, h->left_mb_xy[i>=36], ((i>>2))&3); | 71 | SET_DIAG_MV(/ 2, << 1, h->left_mb_xy[i >= 36], ((i >> 2)) & 3); |
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | #undef SET_DIAG_MV | 74 | #undef SET_DIAG_MV |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | if(topright_ref != PART_NOT_AVAILABLE){ | 77 | if (topright_ref != PART_NOT_AVAILABLE) { |
| 78 | *C= h->mv_cache[list][ i - 8 + part_width ]; | 78 | *C = h->mv_cache[list][i - 8 + part_width]; |
| 79 | return topright_ref; | 79 | return topright_ref; |
| 80 | }else{ | 80 | } else { |
| 81 | tprintf(s->avctx, "topright MV not available\n"); | 81 | tprintf(s->avctx, "topright MV not available\n"); |
| 82 | 82 | ||
| 83 | *C= h->mv_cache[list][ i - 8 - 1 ]; | 83 | *C = h->mv_cache[list][i - 8 - 1]; |
| 84 | return h->ref_cache[list][ i - 8 - 1 ]; | 84 | return h->ref_cache[list][i - 8 - 1]; |
| 85 | } | 85 | } |
| 86 | } | 86 | } |
| 87 | 87 | ||
| @@ -92,53 +92,61 @@ static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, · 4 unmodified lines | |||
| 92 | * @param mx the x component of the predicted motion vector | 92 | * @param mx the x component of the predicted motion vector |
| 93 | * @param my the y component of the predicted motion vector | 93 | * @param my the y component of the predicted motion vector |
| 94 | */ | 94 | */ |
| 95 | static av_always_inline void pred_motion(H264Context * const h, int n, int part_width, int list, int ref, int * const mx, int * const my){ | 95 | static av_always_inline void pred_motion(H264Context *const h, int n, |
| 96 | const int index8= scan8[n]; | 96 | int part_width, int list, int ref, |
| 97 | const int top_ref= h->ref_cache[list][ index8 - 8 ]; | 97 | int *const mx, int *const my) |
| 98 | const int left_ref= h->ref_cache[list][ index8 - 1 ]; | 98 | { |
| 99 | const int16_t * const A= h->mv_cache[list][ index8 - 1 ]; | 99 | const int index8 = scan8[n]; |
| 100 | const int16_t * const B= h->mv_cache[list][ index8 - 8 ]; | 100 | const int top_ref = h->ref_cache[list][index8 - 8]; |
| 101 | const int16_t * C; | 101 | const int left_ref = h->ref_cache[list][index8 - 1]; |
| 102 | const int16_t *const A = h->mv_cache[list][index8 - 1]; | ||
| 103 | const int16_t *const B = h->mv_cache[list][index8 - 8]; | ||
| 104 | const int16_t *C; | ||
| 102 | int diagonal_ref, match_count; | 105 | int diagonal_ref, match_count; |
| 103 | 106 | ||
| 104 | assert(part_width==1 || part_width==2 || part_width==4); | 107 | assert(part_width == 1 || part_width == 2 || part_width == 4); |
| 105 | 108 | ||
| 106 | /* mv_cache | 109 | /* mv_cache |
| 107 | B . . A T T T T | 110 | * B . . A T T T T |
| 108 | U . . L . . , . | 111 | * U . . L . . , . |
| 109 | U . . L . . . . | 112 | * U . . L . . . . |
| 110 | U . . L . . , . | 113 | * U . . L . . , . |
| 111 | . . . L . . . . | 114 | * . . . L . . . . |
| 112 | */ | 115 | */ |
| 113 | 116 | ||
| 114 | diagonal_ref= fetch_diagonal_mv(h, &C, index8, list, part_width); | 117 | diagonal_ref = fetch_diagonal_mv(h, &C, index8, list, part_width); |
| 115 | match_count= (diagonal_ref==ref) + (top_ref==ref) + (left_ref==ref); | 118 | match_count = (diagonal_ref == ref) + (top_ref == ref) + (left_ref == ref); |
| 116 | tprintf(h->s.avctx, "pred_motion match_count=%d\n", match_count); | 119 | tprintf(h->s.avctx, "pred_motion match_count=%d\n", match_count); |
| 117 | if(match_count > 1){ //most common | 120 | if (match_count > 1) { //most common |
| 118 | *mx= mid_pred(A[0], B[0], C[0]); | 121 | *mx = mid_pred(A[0], B[0], C[0]); |
| 119 | *my= mid_pred(A[1], B[1], C[1]); | 122 | *my = mid_pred(A[1], B[1], C[1]); |
| 120 | }else if(match_count==1){ | 123 | } else if (match_count == 1) { |
| 121 | if(left_ref==ref){ | 124 | if (left_ref == ref) { |
| 122 | *mx= A[0]; | 125 | *mx = A[0]; |
| 123 | *my= A[1]; | 126 | *my = A[1]; |
| 124 | }else if(top_ref==ref){ | 127 | } else if (top_ref == ref) { |
| 125 | *mx= B[0]; | 128 | *mx = B[0]; |
| 126 | *my= B[1]; | 129 | *my = B[1]; |
| 127 | }else{ | 130 | } else { |
| 128 | *mx= C[0]; | 131 | *mx = C[0]; |
| 129 | *my= C[1]; | 132 | *my = C[1]; |
| 130 | } | 133 | } |
| 131 | }else{ | 134 | } else { |
| 132 | if(top_ref == PART_NOT_AVAILABLE && diagonal_ref == PART_NOT_AVAILABLE && left_ref != PART_NOT_AVAILABLE){ | 135 | if (top_ref == PART_NOT_AVAILABLE && |
| 133 | *mx= A[0]; | 136 | diagonal_ref == PART_NOT_AVAILABLE && |
| 134 | *my= A[1]; | 137 | left_ref != PART_NOT_AVAILABLE) { |
| 135 | }else{ | 138 | *mx = A[0]; |
| 136 | *mx= mid_pred(A[0], B[0], C[0]); | 139 | *my = A[1]; |
| 137 | *my= mid_pred(A[1], B[1], C[1]); | 140 | } else { |
| 141 | *mx = mid_pred(A[0], B[0], C[0]); | ||
| 142 | *my = mid_pred(A[1], B[1], C[1]); | ||
| 138 | } | 143 | } |
| 139 | } | 144 | } |
| 140 | 145 | ||
| 141 | tprintf(h->s.avctx, "pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n", top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref, A[0], A[1], ref, *mx, *my, h->s.mb_x, h->s.mb_y, n, list); | 146 | tprintf(h->s.avctx, |
| 147 | "pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n", | ||
| 148 | top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref, | ||
| 149 | A[0], A[1], ref, *mx, *my, h->s.mb_x, h->s.mb_y, n, list); | ||
| 142 | } | 150 | } |
| 143 | 151 | ||
| 144 | /** | 152 | /** |
| @@ -147,27 +155,32 @@ static av_always_inline void pred_motion(H264Context * const h, int n, int part_ · 2 unmodified lines | |||
| 147 | * @param mx the x component of the predicted motion vector | 155 | * @param mx the x component of the predicted motion vector |
| 148 | * @param my the y component of the predicted motion vector | 156 | * @param my the y component of the predicted motion vector |
| 149 | */ | 157 | */ |
| 150 | static av_always_inline void pred_16x8_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){ | 158 | static av_always_inline void pred_16x8_motion(H264Context *const h, |
| 151 | if(n==0){ | 159 | int n, int list, int ref, |
| 152 | const int top_ref= h->ref_cache[list][ scan8[0] - 8 ]; | 160 | int *const mx, int *const my) |
| 153 | const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ]; | 161 | { |
| 154 | 162 | if (n == 0) { | |
| 155 | tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", top_ref, B[0], B[1], h->s.mb_x, h->s.mb_y, n, list); | 163 | const int top_ref = h->ref_cache[list][scan8[0] - 8]; |
| 156 | 164 | const int16_t *const B = h->mv_cache[list][scan8[0] - 8]; | |
| 157 | if(top_ref == ref){ | 165 | |
| 158 | *mx= B[0]; | 166 | tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", |
| 159 | *my= B[1]; | 167 | top_ref, B[0], B[1], h->s.mb_x, h->s.mb_y, n, list); |
| 168 | |||
| 169 | if (top_ref == ref) { | ||
| 170 | *mx = B[0]; | ||
| 171 | *my = B[1]; | ||
| 160 | return; | 172 | return; |
| 161 | } | 173 | } |
| 162 | }else{ | 174 | } else { |
| 163 | const int left_ref= h->ref_cache[list][ scan8[8] - 1 ]; | 175 | const int left_ref = h->ref_cache[list][scan8[8] - 1]; |
| 164 | const int16_t * const A= h->mv_cache[list][ scan8[8] - 1 ]; | 176 | const int16_t *const A = h->mv_cache[list][scan8[8] - 1]; |
| 165 | 177 | ||
| 166 | tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list); | 178 | tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", |
| 179 | left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list); | ||
| 167 | 180 | ||
| 168 | if(left_ref == ref){ | 181 | if (left_ref == ref) { |
| 169 | *mx= A[0]; | 182 | *mx = A[0]; |
| 170 | *my= A[1]; | 183 | *my = A[1]; |
| 171 | return; | 184 | return; |
| 172 | } | 185 | } |
| 173 | } | 186 | } |
| @@ -182,29 +195,34 @@ static av_always_inline void pred_16x8_motion(H264Context * const h, int n, int · 8 unmodified lines | |||
| 182 | * @param mx the x component of the predicted motion vector | 195 | * @param mx the x component of the predicted motion vector |
| 183 | * @param my the y component of the predicted motion vector | 196 | * @param my the y component of the predicted motion vector |
| 184 | */ | 197 | */ |
| 185 | static av_always_inline void pred_8x16_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){ | 198 | static av_always_inline void pred_8x16_motion(H264Context *const h, |
| 186 | if(n==0){ | 199 | int n, int list, int ref, |
| 187 | const int left_ref= h->ref_cache[list][ scan8[0] - 1 ]; | 200 | int *const mx, int *const my) |
| 188 | const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ]; | 201 | { |
| 189 | 202 | if (n == 0) { | |
| 190 | tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list); | 203 | const int left_ref = h->ref_cache[list][scan8[0] - 1]; |
| 191 | 204 | const int16_t *const A = h->mv_cache[list][scan8[0] - 1]; | |
| 192 | if(left_ref == ref){ | 205 | |
| 193 | *mx= A[0]; | 206 | tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", |
| 194 | *my= A[1]; | 207 | left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list); |
| 208 | |||
| 209 | if (left_ref == ref) { | ||
| 210 | *mx = A[0]; | ||
| 211 | *my = A[1]; | ||
| 195 | return; | 212 | return; |
| 196 | } | 213 | } |
| 197 | }else{ | 214 | } else { |
| 198 | const int16_t * C; | 215 | const int16_t *C; |
| 199 | int diagonal_ref; | 216 | int diagonal_ref; |
| 200 | 217 | ||
| 201 | diagonal_ref= fetch_diagonal_mv(h, &C, scan8[4], list, 2); | 218 | diagonal_ref = fetch_diagonal_mv(h, &C, scan8[4], list, 2); |
| 202 | 219 | ||
| 203 | tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", diagonal_ref, C[0], C[1], h->s.mb_x, h->s.mb_y, n, list); | 220 | tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", |
| 221 | diagonal_ref, C[0], C[1], h->s.mb_x, h->s.mb_y, n, list); | ||
| 204 | 222 | ||
| 205 | if(diagonal_ref == ref){ | 223 | if (diagonal_ref == ref) { |
| 206 | *mx= C[0]; | 224 | *mx = C[0]; |
| 207 | *my= C[1]; | 225 | *my = C[1]; |
| 208 | return; | 226 | return; |
| 209 | } | 227 | } |
| 210 | } | 228 | } |
| @@ -213,168 +231,174 @@ static av_always_inline void pred_8x16_motion(H264Context * const h, int n, int · 2 unmodified lines | |||
| 213 | pred_motion(h, n, 2, list, ref, mx, my); | 231 | pred_motion(h, n, 2, list, ref, mx, my); |
| 214 | } | 232 | } |
| 215 | 233 | ||
| 216 | #define FIX_MV_MBAFF(type, refn, mvn, idx)\ | 234 | #define FIX_MV_MBAFF(type, refn, mvn, idx) \ |
| 217 | if(FRAME_MBAFF){\ | 235 | if (FRAME_MBAFF) { \ |
| 218 | if(MB_FIELD){\ | 236 | if (MB_FIELD) { \ |
| 219 | if(!IS_INTERLACED(type)){\ | 237 | if (!IS_INTERLACED(type)) { \ |
| 220 | refn <<= 1;\ | 238 | refn <<= 1; \ |
| 221 | AV_COPY32(mvbuf[idx], mvn);\ | 239 | AV_COPY32(mvbuf[idx], mvn); \ |
| 222 | mvbuf[idx][1] /= 2;\ | 240 | mvbuf[idx][1] /= 2; \ |
| 223 | mvn = mvbuf[idx];\ | 241 | mvn = mvbuf[idx]; \ |
| 224 | }\ | 242 | } \ |
| 225 | }else{\ | 243 | } else { \ |
| 226 | if(IS_INTERLACED(type)){\ | 244 | if (IS_INTERLACED(type)) { \ |
| 227 | refn >>= 1;\ | 245 | refn >>= 1; \ |
| 228 | AV_COPY32(mvbuf[idx], mvn);\ | 246 | AV_COPY32(mvbuf[idx], mvn); \ |
| 229 | mvbuf[idx][1] <<= 1;\ | 247 | mvbuf[idx][1] <<= 1; \ |
| 230 | mvn = mvbuf[idx];\ | 248 | mvn = mvbuf[idx]; \ |
| 231 | }\ | 249 | } \ |
| 232 | }\ | 250 | } \ |
| 233 | } | 251 | } |
| 234 | 252 | ||
| 235 | static av_always_inline void pred_pskip_motion(H264Context * const h){ | 253 | static av_always_inline void pred_pskip_motion(H264Context *const h) |
| 236 | DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = {0}; | 254 | { |
| 255 | DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = { 0 }; | ||
| 237 | DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2]; | 256 | DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2]; |
| 238 | MpegEncContext * const s = &h->s; | 257 | MpegEncContext *const s = &h->s; |
| 239 | int8_t *ref = s->current_picture.f.ref_index[0]; | 258 | int8_t *ref = s->current_picture.f.ref_index[0]; |
| 240 | int16_t (*mv)[2] = s->current_picture.f.motion_val[0]; | 259 | int16_t(*mv)[2] = s->current_picture.f.motion_val[0]; |
| 241 | int top_ref, left_ref, diagonal_ref, match_count, mx, my; | 260 | int top_ref, left_ref, diagonal_ref, match_count, mx, my; |
| 242 | const int16_t *A, *B, *C; | 261 | const int16_t *A, *B, *C; |
| 243 | int b_stride = h->b_stride; | 262 | int b_stride = h->b_stride; |
| 244 | 263 | ||
| 245 | fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1); | 264 | fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1); |
| 246 | 265 | ||
| 247 | /* To avoid doing an entire fill_decode_caches, we inline the relevant parts here. | 266 | /* To avoid doing an entire fill_decode_caches, we inline the relevant |
| 248 | * FIXME: this is a partial duplicate of the logic in fill_decode_caches, but it's | 267 | * parts here. |
| 249 | * faster this way. Is there a way to avoid this duplication? | 268 | * FIXME: this is a partial duplicate of the logic in fill_decode_caches, |
| 269 | * but it's faster this way. Is there a way to avoid this duplication? | ||
| 250 | */ | 270 | */ |
| 251 | if(USES_LIST(h->left_type[LTOP], 0)){ | 271 | if (USES_LIST(h->left_type[LTOP], 0)) { |
| 252 | left_ref = ref[4*h->left_mb_xy[LTOP] + 1 + (h->left_block[0]&~1)]; | 272 | left_ref = ref[4 * h->left_mb_xy[LTOP] + 1 + (h->left_block[0] & ~1)]; |
| 253 | A = mv[h->mb2b_xy[h->left_mb_xy[LTOP]] + 3 + b_stride*h->left_block[0]]; | 273 | A = mv[h->mb2b_xy[h->left_mb_xy[LTOP]] + 3 + b_stride * h->left_block[0]]; |
| 254 | FIX_MV_MBAFF(h->left_type[LTOP], left_ref, A, 0); | 274 | FIX_MV_MBAFF(h->left_type[LTOP], left_ref, A, 0); |
| 255 | if(!(left_ref | AV_RN32A(A))){ | 275 | if (!(left_ref | AV_RN32A(A))) |
| 256 | goto zeromv; | 276 | goto zeromv; |
| 257 | } | 277 | } else if (h->left_type[LTOP]) { |
| 258 | }else if(h->left_type[LTOP]){ | ||
| 259 | left_ref = LIST_NOT_USED; | 278 | left_ref = LIST_NOT_USED; |
| 260 | A = zeromv; | 279 | A = zeromv; |
| 261 | }else{ | 280 | } else { |
| 262 | goto zeromv; | 281 | goto zeromv; |
| 263 | } | 282 | } |
| 264 | 283 | ||
| 265 | if(USES_LIST(h->top_type, 0)){ | 284 | if (USES_LIST(h->top_type, 0)) { |
| 266 | top_ref = ref[4*h->top_mb_xy + 2]; | 285 | top_ref = ref[4 * h->top_mb_xy + 2]; |
| 267 | B = mv[h->mb2b_xy[h->top_mb_xy] + 3*b_stride]; | 286 | B = mv[h->mb2b_xy[h->top_mb_xy] + 3 * b_stride]; |
| 268 | FIX_MV_MBAFF(h->top_type, top_ref, B, 1); | 287 | FIX_MV_MBAFF(h->top_type, top_ref, B, 1); |
| 269 | if(!(top_ref | AV_RN32A(B))){ | 288 | if (!(top_ref | AV_RN32A(B))) |
| 270 | goto zeromv; | 289 | goto zeromv; |
| 271 | } | 290 | } else if (h->top_type) { |
| 272 | }else if(h->top_type){ | ||
| 273 | top_ref = LIST_NOT_USED; | 291 | top_ref = LIST_NOT_USED; |
| 274 | B = zeromv; | 292 | B = zeromv; |
| 275 | }else{ | 293 | } else { |
| 276 | goto zeromv; | 294 | goto zeromv; |
| 277 | } | 295 | } |
| 278 | 296 | ||
| 279 | tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y); | 297 | tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", |
| 298 | top_ref, left_ref, h->s.mb_x, h->s.mb_y); | ||
| 280 | 299 | ||
| 281 | if(USES_LIST(h->topright_type, 0)){ | 300 | if (USES_LIST(h->topright_type, 0)) { |
| 282 | diagonal_ref = ref[4*h->topright_mb_xy + 2]; | 301 | diagonal_ref = ref[4 * h->topright_mb_xy + 2]; |
| 283 | C = mv[h->mb2b_xy[h->topright_mb_xy] + 3*b_stride]; | 302 | C = mv[h->mb2b_xy[h->topright_mb_xy] + 3 * b_stride]; |
| 284 | FIX_MV_MBAFF(h->topright_type, diagonal_ref, C, 2); | 303 | FIX_MV_MBAFF(h->topright_type, diagonal_ref, C, 2); |
| 285 | }else if(h->topright_type){ | 304 | } else if (h->topright_type) { |
| 286 | diagonal_ref = LIST_NOT_USED; | 305 | diagonal_ref = LIST_NOT_USED; |
| 287 | C = zeromv; | 306 | C = zeromv; |
| 288 | }else{ | 307 | } else { |
| 289 | if(USES_LIST(h->topleft_type, 0)){ | 308 | if (USES_LIST(h->topleft_type, 0)) { |
| 290 | diagonal_ref = ref[4*h->topleft_mb_xy + 1 + (h->topleft_partition & 2)]; | 309 | diagonal_ref = ref[4 * h->topleft_mb_xy + 1 + |
| 291 | C = mv[h->mb2b_xy[h->topleft_mb_xy] + 3 + b_stride + (h->topleft_partition & 2*b_stride)]; | 310 | (h->topleft_partition & 2)]; |
| 311 | C = mv[h->mb2b_xy[h->topleft_mb_xy] + 3 + b_stride + | ||
| 312 | (h->topleft_partition & 2 * b_stride)]; | ||
| 292 | FIX_MV_MBAFF(h->topleft_type, diagonal_ref, C, 2); | 313 | FIX_MV_MBAFF(h->topleft_type, diagonal_ref, C, 2); |
| 293 | }else if(h->topleft_type){ | 314 | } else if (h->topleft_type) { |
| 294 | diagonal_ref = LIST_NOT_USED; | 315 | diagonal_ref = LIST_NOT_USED; |
| 295 | C = zeromv; | 316 | C = zeromv; |
| 296 | }else{ | 317 | } else { |
| 297 | diagonal_ref = PART_NOT_AVAILABLE; | 318 | diagonal_ref = PART_NOT_AVAILABLE; |
| 298 | C = zeromv; | 319 | C = zeromv; |
| 299 | } | 320 | } |
| 300 | } | 321 | } |
| 301 | 322 | ||
| 302 | match_count= !diagonal_ref + !top_ref + !left_ref; | 323 | match_count = !diagonal_ref + !top_ref + !left_ref; |
| 303 | tprintf(h->s.avctx, "pred_pskip_motion match_count=%d\n", match_count); | 324 | tprintf(h->s.avctx, "pred_pskip_motion match_count=%d\n", match_count); |
| 304 | if(match_count > 1){ | 325 | if (match_count > 1) { |
| 305 | mx = mid_pred(A[0], B[0], C[0]); | 326 | mx = mid_pred(A[0], B[0], C[0]); |
| 306 | my = mid_pred(A[1], B[1], C[1]); | 327 | my = mid_pred(A[1], B[1], C[1]); |
| 307 | }else if(match_count==1){ | 328 | } else if (match_count == 1) { |
| 308 | if(!left_ref){ | 329 | if (!left_ref) { |
| 309 | mx = A[0]; | 330 | mx = A[0]; |
| 310 | my = A[1]; | 331 | my = A[1]; |
| 311 | }else if(!top_ref){ | 332 | } else if (!top_ref) { |
| 312 | mx = B[0]; | 333 | mx = B[0]; |
| 313 | my = B[1]; | 334 | my = B[1]; |
| 314 | }else{ | 335 | } else { |
| 315 | mx = C[0]; | 336 | mx = C[0]; |
| 316 | my = C[1]; | 337 | my = C[1]; |
| 317 | } | 338 | } |
| 318 | }else{ | 339 | } else { |
| 319 | mx = mid_pred(A[0], B[0], C[0]); | 340 | mx = mid_pred(A[0], B[0], C[0]); |
| 320 | my = mid_pred(A[1], B[1], C[1]); | 341 | my = mid_pred(A[1], B[1], C[1]); |
| 321 | } | 342 | } |
| 322 | 343 | ||
| 323 | fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx,my), 4); | 344 | fill_rectangle(h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx, my), 4); |
| 324 | return; | 345 | return; |
| 346 | |||
| 325 | zeromv: | 347 | zeromv: |
| 326 | fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4); | 348 | fill_rectangle(h->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4); |
| 327 | return; | 349 | return; |
| 328 | } | 350 | } |
| 329 | 351 | ||
| 330 | static void fill_decode_neighbors(H264Context *h, int mb_type){ | 352 | static void fill_decode_neighbors(H264Context *h, int mb_type) |
| 331 | MpegEncContext * const s = &h->s; | 353 | { |
| 332 | const int mb_xy= h->mb_xy; | 354 | MpegEncContext *const s = &h->s; |
| 355 | const int mb_xy = h->mb_xy; | ||
| 333 | int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; | 356 | int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; |
| 334 | static const uint8_t left_block_options[4][32]={ | 357 | static const uint8_t left_block_options[4][32] = { |
| 335 | {0,1,2,3,7,10,8,11,3+0*4, 3+1*4, 3+2*4, 3+3*4, 1+4*4, 1+8*4, 1+5*4, 1+9*4}, | 358 | { 0, 1, 2, 3, 7, 10, 8, 11, 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 5 * 4, 1 + 9 * 4 }, |
| 336 | {2,2,3,3,8,11,8,11,3+2*4, 3+2*4, 3+3*4, 3+3*4, 1+5*4, 1+9*4, 1+5*4, 1+9*4}, | 359 | { 2, 2, 3, 3, 8, 11, 8, 11, 3 + 2 * 4, 3 + 2 * 4, 3 + 3 * 4, 3 + 3 * 4, 1 + 5 * 4, 1 + 9 * 4, 1 + 5 * 4, 1 + 9 * 4 }, |
| 337 | {0,0,1,1,7,10,7,10,3+0*4, 3+0*4, 3+1*4, 3+1*4, 1+4*4, 1+8*4, 1+4*4, 1+8*4}, | 360 | { 0, 0, 1, 1, 7, 10, 7, 10, 3 + 0 * 4, 3 + 0 * 4, 3 + 1 * 4, 3 + 1 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 }, |
| 338 | {0,2,0,2,7,10,7,10,3+0*4, 3+2*4, 3+0*4, 3+2*4, 1+4*4, 1+8*4, 1+4*4, 1+8*4} | 361 | { 0, 2, 0, 2, 7, 10, 7, 10, 3 + 0 * 4, 3 + 2 * 4, 3 + 0 * 4, 3 + 2 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 } |
| 339 | }; | 362 | }; |
| 340 | 363 | ||
| 341 | h->topleft_partition= -1; | 364 | h->topleft_partition = -1; |
| 342 | 365 | ||
| 343 | top_xy = mb_xy - (s->mb_stride << MB_FIELD); | 366 | top_xy = mb_xy - (s->mb_stride << MB_FIELD); |
| 344 | 367 | ||
| 345 | /* Wow, what a mess, why didn't they simplify the interlacing & intra | 368 | /* Wow, what a mess, why didn't they simplify the interlacing & intra |
| 346 | * stuff, I can't imagine that these complex rules are worth it. */ | 369 | * stuff, I can't imagine that these complex rules are worth it. */ |
| 347 | 370 | ||
| 348 | topleft_xy = top_xy - 1; | 371 | topleft_xy = top_xy - 1; |
| 349 | topright_xy= top_xy + 1; | 372 | topright_xy = top_xy + 1; |
| 350 | left_xy[LBOT] = left_xy[LTOP] = mb_xy-1; | 373 | left_xy[LBOT] = left_xy[LTOP] = mb_xy - 1; |
| 351 | h->left_block = left_block_options[0]; | 374 | h->left_block = left_block_options[0]; |
| 352 | if(FRAME_MBAFF){ | 375 | if (FRAME_MBAFF) { |
| 353 | const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]); | 376 | const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]); |
| 354 | const int curr_mb_field_flag = IS_INTERLACED(mb_type); | 377 | const int curr_mb_field_flag = IS_INTERLACED(mb_type); |
| 355 | if(s->mb_y&1){ | 378 | if (s->mb_y & 1) { |
| 356 | if (left_mb_field_flag != curr_mb_field_flag) { | 379 | if (left_mb_field_flag != curr_mb_field_flag) { |
| 357 | left_xy[LBOT] = left_xy[LTOP] = mb_xy - s->mb_stride - 1; | 380 | left_xy[LBOT] = left_xy[LTOP] = mb_xy - s->mb_stride - 1; |
| 358 | if (curr_mb_field_flag) { | 381 | if (curr_mb_field_flag) { |
| 359 | left_xy[LBOT] += s->mb_stride; | 382 | left_xy[LBOT] += s->mb_stride; |
| 360 | h->left_block = left_block_options[3]; | 383 | h->left_block = left_block_options[3]; |
| 361 | } else { | 384 | } else { |
| 362 | topleft_xy += s->mb_stride; | 385 | topleft_xy += s->mb_stride; |
| 363 | // take top left mv from the middle of the mb, as opposed to all other modes which use the bottom right partition | 386 | /* take top left mv from the middle of the mb, as opposed |
| 387 | * to all other modes which use the bottom right partition */ | ||
| 364 | h->topleft_partition = 0; | 388 | h->topleft_partition = 0; |
| 365 | h->left_block = left_block_options[1]; | 389 | h->left_block = left_block_options[1]; |
| 366 | } | 390 | } |
| 367 | } | 391 | } |
| 368 | }else{ | 392 | } else { |
| 369 | if(curr_mb_field_flag){ | 393 | if (curr_mb_field_flag) { |
| 370 | topleft_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy - 1] >> 7) & 1) - 1); | 394 | topleft_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy - 1] >> 7) & 1) - 1); |
| 371 | topright_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy + 1] >> 7) & 1) - 1); | 395 | topright_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy + 1] >> 7) & 1) - 1); |
| 372 | top_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy ] >> 7) & 1) - 1); | 396 | top_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy] >> 7) & 1) - 1); |
| 373 | } | 397 | } |
| 374 | if (left_mb_field_flag != curr_mb_field_flag) { | 398 | if (left_mb_field_flag != curr_mb_field_flag) { |
| 375 | if (curr_mb_field_flag) { | 399 | if (curr_mb_field_flag) { |
| 376 | left_xy[LBOT] += s->mb_stride; | 400 | left_xy[LBOT] += s->mb_stride; |
| 377 | h->left_block = left_block_options[3]; | 401 | h->left_block = left_block_options[3]; |
| 378 | } else { | 402 | } else { |
| 379 | h->left_block = left_block_options[2]; | 403 | h->left_block = left_block_options[2]; |
| 380 | } | 404 | } |
| @@ -382,9 +406,9 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){ · 1 unmodified line | |||
| 382 | } | 406 | } |
| 383 | } | 407 | } |
| 384 | 408 | ||
| 385 | h->topleft_mb_xy = topleft_xy; | 409 | h->topleft_mb_xy = topleft_xy; |
| 386 | h->top_mb_xy = top_xy; | 410 | h->top_mb_xy = top_xy; |
| 387 | h->topright_mb_xy= topright_xy; | 411 | h->topright_mb_xy = topright_xy; |
| 388 | h->left_mb_xy[LTOP] = left_xy[LTOP]; | 412 | h->left_mb_xy[LTOP] = left_xy[LTOP]; |
| 389 | h->left_mb_xy[LBOT] = left_xy[LBOT]; | 413 | h->left_mb_xy[LBOT] = left_xy[LBOT]; |
| 390 | //FIXME do we need all in the context? | 414 | //FIXME do we need all in the context? |
| @@ -395,351 +419,372 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){ · 4 unmodified lines | |||
| 395 | h->left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]]; | 419 | h->left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]]; |
| 396 | h->left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]]; | 420 | h->left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]]; |
| 397 | 421 | ||
| 398 | if(FMO){ | 422 | if (FMO) { |
| 399 | if(h->slice_table[topleft_xy ] != h->slice_num) h->topleft_type = 0; | 423 | if (h->slice_table[topleft_xy] != h->slice_num) |
| 400 | if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0; | 424 | h->topleft_type = 0; |
| 401 | if(h->slice_table[left_xy[LTOP] ] != h->slice_num) h->left_type[LTOP] = h->left_type[LBOT] = 0; | 425 | if (h->slice_table[top_xy] != h->slice_num) |
| 402 | }else{ | 426 | h->top_type = 0; |
| 403 | if(h->slice_table[topleft_xy ] != h->slice_num){ | 427 | if (h->slice_table[left_xy[LTOP]] != h->slice_num) |
| 428 | h->left_type[LTOP] = h->left_type[LBOT] = 0; | ||
| 429 | } else { | ||
| 430 | if (h->slice_table[topleft_xy] != h->slice_num) { | ||
| 404 | h->topleft_type = 0; | 431 | h->topleft_type = 0; |
| 405 | if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0; | 432 | if (h->slice_table[top_xy] != h->slice_num) |
| 406 | if(h->slice_table[left_xy[LTOP] ] != h->slice_num) h->left_type[LTOP] = h->left_type[LBOT] = 0; | 433 | h->top_type = 0; |
| 434 | if (h->slice_table[left_xy[LTOP]] != h->slice_num) | ||
| 435 | h->left_type[LTOP] = h->left_type[LBOT] = 0; | ||
| 407 | } | 436 | } |
| 408 | } | 437 | } |
| 409 | if(h->slice_table[topright_xy] != h->slice_num) h->topright_type= 0; | 438 | if (h->slice_table[topright_xy] != h->slice_num) |
| 439 | h->topright_type = 0; | ||
| 410 | } | 440 | } |
| 411 | 441 | ||
| 412 | static void fill_decode_caches(H264Context *h, int mb_type){ | 442 | static void fill_decode_caches(H264Context *h, int mb_type) |
| 413 | MpegEncContext * const s = &h->s; | 443 | { |
| 444 | MpegEncContext *const s = &h->s; | ||
| 414 | int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; | 445 | int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; |
| 415 | int topleft_type, top_type, topright_type, left_type[LEFT_MBS]; | 446 | int topleft_type, top_type, topright_type, left_type[LEFT_MBS]; |
| 416 | const uint8_t * left_block= h->left_block; | 447 | const uint8_t *left_block = h->left_block; |
| 417 | int i; | 448 | int i; |
| 418 | uint8_t *nnz; | 449 | uint8_t *nnz; |
| 419 | uint8_t *nnz_cache; | 450 | uint8_t *nnz_cache; |
| 420 | 451 | ||
| 421 | topleft_xy = h->topleft_mb_xy; | 452 | topleft_xy = h->topleft_mb_xy; |
| 422 | top_xy = h->top_mb_xy; | 453 | top_xy = h->top_mb_xy; |
| 423 | topright_xy = h->topright_mb_xy; | 454 | topright_xy = h->topright_mb_xy; |
| 424 | left_xy[LTOP] = h->left_mb_xy[LTOP]; | 455 | left_xy[LTOP] = h->left_mb_xy[LTOP]; |
| 425 | left_xy[LBOT] = h->left_mb_xy[LBOT]; | 456 | left_xy[LBOT] = h->left_mb_xy[LBOT]; |
| 426 | topleft_type = h->topleft_type; | 457 | topleft_type = h->topleft_type; |
| 427 | top_type = h->top_type; | 458 | top_type = h->top_type; |
| 428 | topright_type = h->topright_type; | 459 | topright_type = h->topright_type; |
| 429 | left_type[LTOP]= h->left_type[LTOP]; | 460 | left_type[LTOP] = h->left_type[LTOP]; |
| 430 | left_type[LBOT]= h->left_type[LBOT]; | 461 | left_type[LBOT] = h->left_type[LBOT]; |
| 431 | 462 | ||
| 432 | if(!IS_SKIP(mb_type)){ | 463 | if (!IS_SKIP(mb_type)) { |
| 433 | if(IS_INTRA(mb_type)){ | 464 | if (IS_INTRA(mb_type)) { |
| 434 | int type_mask= h->pps.constrained_intra_pred ? IS_INTRA(-1) : -1; | 465 | int type_mask = h->pps.constrained_intra_pred ? IS_INTRA(-1) : -1; |
| 435 | h->topleft_samples_available= | 466 | h->topleft_samples_available = |
| 436 | h->top_samples_available= | 467 | h->top_samples_available = |
| 437 | h->left_samples_available= 0xFFFF; | 468 | h->left_samples_available = 0xFFFF; |
| 438 | h->topright_samples_available= 0xEEEA; | 469 | h->topright_samples_available = 0xEEEA; |
| 439 | 470 | ||
| 440 | if(!(top_type & type_mask)){ | 471 | if (!(top_type & type_mask)) { |
| 441 | h->topleft_samples_available= 0xB3FF; | 472 | h->topleft_samples_available = 0xB3FF; |
| 442 | h->top_samples_available= 0x33FF; | 473 | h->top_samples_available = 0x33FF; |
| 443 | h->topright_samples_available= 0x26EA; | 474 | h->topright_samples_available = 0x26EA; |
| 444 | } | 475 | } |
| 445 | if(IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])){ | 476 | if (IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])) { |
| 446 | if(IS_INTERLACED(mb_type)){ | 477 | if (IS_INTERLACED(mb_type)) { |
| 447 | if(!(left_type[LTOP] & type_mask)){ | 478 | if (!(left_type[LTOP] & type_mask)) { |
| 448 | h->topleft_samples_available&= 0xDFFF; | 479 | h->topleft_samples_available &= 0xDFFF; |
| 449 | h->left_samples_available&= 0x5FFF; | 480 | h->left_samples_available &= 0x5FFF; |
| 450 | } | 481 | } |
| 451 | if(!(left_type[LBOT] & type_mask)){ | 482 | if (!(left_type[LBOT] & type_mask)) { |
| 452 | h->topleft_samples_available&= 0xFF5F; | 483 | h->topleft_samples_available &= 0xFF5F; |
| 453 | h->left_samples_available&= 0xFF5F; | 484 | h->left_samples_available &= 0xFF5F; |
| 454 | } | 485 | } |
| 455 | }else{ | 486 | } else { |
| 456 | int left_typei = s->current_picture.f.mb_type[left_xy[LTOP] + s->mb_stride]; | 487 | int left_typei = s->current_picture.f.mb_type[left_xy[LTOP] + s->mb_stride]; |
| 457 | 488 | ||
| 458 | assert(left_xy[LTOP] == left_xy[LBOT]); | 489 | assert(left_xy[LTOP] == left_xy[LBOT]); |
| 459 | if(!((left_typei & type_mask) && (left_type[LTOP] & type_mask))){ | 490 | if (!((left_typei & type_mask) && (left_type[LTOP] & type_mask))) { |
| 460 | h->topleft_samples_available&= 0xDF5F; | 491 | h->topleft_samples_available &= 0xDF5F; |
| 461 | h->left_samples_available&= 0x5F5F; | 492 | h->left_samples_available &= 0x5F5F; |
| 462 | } | 493 | } |
| 463 | } | 494 | } |
| 464 | }else{ | 495 | } else { |
| 465 | if(!(left_type[LTOP] & type_mask)){ | 496 | if (!(left_type[LTOP] & type_mask)) { |
| 466 | h->topleft_samples_available&= 0xDF5F; | 497 | h->topleft_samples_available &= 0xDF5F; |
| 467 | h->left_samples_available&= 0x5F5F; | 498 | h->left_samples_available &= 0x5F5F; |
| 468 | } | 499 | } |
| 469 | } | 500 | } |
| 470 | 501 | ||
| 471 | if(!(topleft_type & type_mask)) | 502 | if (!(topleft_type & type_mask)) |
| 472 | h->topleft_samples_available&= 0x7FFF; | 503 | h->topleft_samples_available &= 0x7FFF; |
| 473 | 504 | ||
| 474 | if(!(topright_type & type_mask)) | 505 | if (!(topright_type & type_mask)) |
| 475 | h->topright_samples_available&= 0xFBFF; | 506 | h->topright_samples_available &= 0xFBFF; |
| 476 | 507 | ||
| 477 | if(IS_INTRA4x4(mb_type)){ | 508 | if (IS_INTRA4x4(mb_type)) { |
| 478 | if(IS_INTRA4x4(top_type)){ | 509 | if (IS_INTRA4x4(top_type)) { |
| 479 | AV_COPY32(h->intra4x4_pred_mode_cache+4+8*0, h->intra4x4_pred_mode + h->mb2br_xy[top_xy]); | 510 | AV_COPY32(h->intra4x4_pred_mode_cache + 4 + 8 * 0, h->intra4x4_pred_mode + h->mb2br_xy[top_xy]); |
| 480 | }else{ | 511 | } else { |
| 481 | h->intra4x4_pred_mode_cache[4+8*0]= | 512 | h->intra4x4_pred_mode_cache[4 + 8 * 0] = |
| 482 | h->intra4x4_pred_mode_cache[5+8*0]= | 513 | h->intra4x4_pred_mode_cache[5 + 8 * 0] = |
| 483 | h->intra4x4_pred_mode_cache[6+8*0]= | 514 | h->intra4x4_pred_mode_cache[6 + 8 * 0] = |
| 484 | h->intra4x4_pred_mode_cache[7+8*0]= 2 - 3*!(top_type & type_mask); | 515 | h->intra4x4_pred_mode_cache[7 + 8 * 0] = 2 - 3 * !(top_type & type_mask); |
| 485 | } | 516 | } |
| 486 | for(i=0; i<2; i++){ | 517 | for (i = 0; i < 2; i++) { |
| 487 | if(IS_INTRA4x4(left_type[LEFT(i)])){ | 518 | if (IS_INTRA4x4(left_type[LEFT(i)])) { |
| 488 | int8_t *mode= h->intra4x4_pred_mode + h->mb2br_xy[left_xy[LEFT(i)]]; | 519 | int8_t *mode = h->intra4x4_pred_mode + h->mb2br_xy[left_xy[LEFT(i)]]; |
| 489 | h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= mode[6-left_block[0+2*i]]; | 520 | h->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] = mode[6 - left_block[0 + 2 * i]]; |
| 490 | h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= mode[6-left_block[1+2*i]]; | 521 | h->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = mode[6 - left_block[1 + 2 * i]]; |
| 491 | }else{ | 522 | } else { |
| 492 | h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= | 523 | h->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] = |
| 493 | h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= 2 - 3*!(left_type[LEFT(i)] & type_mask); | 524 | h->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = 2 - 3 * !(left_type[LEFT(i)] & type_mask); |
| 494 | } | 525 | } |
| 495 | } | 526 | } |
| 496 | } | 527 | } |
| 497 | } | 528 | } |
| 498 | 529 | ||
| 499 | 530 | /* | |
| 500 | /* | 531 | * 0 . T T. T T T T |
| 501 | 0 . T T. T T T T | 532 | * 1 L . .L . . . . |
| 502 | 1 L . .L . . . . | 533 | * 2 L . .L . . . . |
| 503 | 2 L . .L . . . . | 534 | * 3 . T TL . . . . |
| 504 | 3 . T TL . . . . | 535 | * 4 L . .L . . . . |
| 505 | 4 L . .L . . . . | 536 | * 5 L . .. . . . . |
| 506 | 5 L . .. . . . . | 537 | */ |
| 507 | */ | 538 | /* FIXME: constraint_intra_pred & partitioning & nnz |
| 508 | //FIXME constraint_intra_pred & partitioning & nnz (let us hope this is just a typo in the spec) | 539 | * (let us hope this is just a typo in the spec) */ |
| 509 | nnz_cache = h->non_zero_count_cache; | 540 | nnz_cache = h->non_zero_count_cache; |
| 510 | if(top_type){ | 541 | if (top_type) { |
| 511 | nnz = h->non_zero_count[top_xy]; | 542 | nnz = h->non_zero_count[top_xy]; |
| 512 | AV_COPY32(&nnz_cache[4+8* 0], &nnz[4*3]); | 543 | AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[4 * 3]); |
| 513 | if(!s->chroma_y_shift){ | 544 | if (!s->chroma_y_shift) { |
| 514 | AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 7]); | 545 | AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 7]); |
| 515 | AV_COPY32(&nnz_cache[4+8*10], &nnz[4*11]); | 546 | AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 11]); |
| 516 | }else{ | 547 | } else { |
| 517 | AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 5]); | 548 | AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 5]); |
| 518 | AV_COPY32(&nnz_cache[4+8*10], &nnz[4* 9]); | 549 | AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 9]); |
| 550 | } | ||
| 551 | } else { | ||
| 552 | uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040; | ||
| 553 | AV_WN32A(&nnz_cache[4 + 8 * 0], top_empty); | ||
| 554 | AV_WN32A(&nnz_cache[4 + 8 * 5], top_empty); | ||
| 555 | AV_WN32A(&nnz_cache[4 + 8 * 10], top_empty); | ||
| 519 | } | 556 | } |
| 520 | }else{ | ||
| 521 | uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040; | ||
| 522 | AV_WN32A(&nnz_cache[4+8* 0], top_empty); | ||
| 523 | AV_WN32A(&nnz_cache[4+8* 5], top_empty); | ||
| 524 | AV_WN32A(&nnz_cache[4+8*10], top_empty); | ||
| 525 | } | ||
| 526 | 557 | ||
| 527 | for (i=0; i<2; i++) { | 558 | for (i = 0; i < 2; i++) { |
| 528 | if(left_type[LEFT(i)]){ | 559 | if (left_type[LEFT(i)]) { |
| 529 | nnz = h->non_zero_count[left_xy[LEFT(i)]]; | 560 | nnz = h->non_zero_count[left_xy[LEFT(i)]]; |
| 530 | nnz_cache[3+8* 1 + 2*8*i]= nnz[left_block[8+0+2*i]]; | 561 | nnz_cache[3 + 8 * 1 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i]]; |
| 531 | nnz_cache[3+8* 2 + 2*8*i]= nnz[left_block[8+1+2*i]]; | 562 | nnz_cache[3 + 8 * 2 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i]]; |
| 532 | if(CHROMA444){ | 563 | if (CHROMA444) { |
| 533 | nnz_cache[3+8* 6 + 2*8*i]= nnz[left_block[8+0+2*i]+4*4]; | 564 | nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 4 * 4]; |
| 534 | nnz_cache[3+8* 7 + 2*8*i]= nnz[left_block[8+1+2*i]+4*4]; | 565 | nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 4 * 4]; |
| 535 | nnz_cache[3+8*11 + 2*8*i]= nnz[left_block[8+0+2*i]+8*4]; | 566 | nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 8 * 4]; |
| 536 | nnz_cache[3+8*12 + 2*8*i]= nnz[left_block[8+1+2*i]+8*4]; | 567 | nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 8 * 4]; |
| 537 | }else if(CHROMA422) { | 568 | } else if (CHROMA422) { |
| 538 | nnz_cache[3+8* 6 + 2*8*i]= nnz[left_block[8+0+2*i]-2+4*4]; | 569 | nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 4 * 4]; |
| 539 | nnz_cache[3+8* 7 + 2*8*i]= nnz[left_block[8+1+2*i]-2+4*4]; | 570 | nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 4 * 4]; |
| 540 | nnz_cache[3+8*11 + 2*8*i]= nnz[left_block[8+0+2*i]-2+8*4]; | 571 | nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 8 * 4]; |
| 541 | nnz_cache[3+8*12 + 2*8*i]= nnz[left_block[8+1+2*i]-2+8*4]; | 572 | nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 8 * 4]; |
| 542 | }else{ | 573 | } else { |
| 543 | nnz_cache[3+8* 6 + 8*i]= nnz[left_block[8+4+2*i]]; | 574 | nnz_cache[3 + 8 * 6 + 8 * i] = nnz[left_block[8 + 4 + 2 * i]]; |
| 544 | nnz_cache[3+8*11 + 8*i]= nnz[left_block[8+5+2*i]]; | 575 | nnz_cache[3 + 8 * 11 + 8 * i] = nnz[left_block[8 + 5 + 2 * i]]; |
| 576 | } | ||
| 577 | } else { | ||
| 578 | nnz_cache[3 + 8 * 1 + 2 * 8 * i] = | ||
| 579 | nnz_cache[3 + 8 * 2 + 2 * 8 * i] = | ||
| 580 | nnz_cache[3 + 8 * 6 + 2 * 8 * i] = | ||
| 581 | nnz_cache[3 + 8 * 7 + 2 * 8 * i] = | ||
| 582 | nnz_cache[3 + 8 * 11 + 2 * 8 * i] = | ||
| 583 | nnz_cache[3 + 8 * 12 + 2 * 8 * i] = CABAC && !IS_INTRA(mb_type) ? 0 : 64; | ||
| 545 | } | 584 | } |
| 546 | }else{ | ||
| 547 | nnz_cache[3+8* 1 + 2*8*i]= | ||
| 548 | nnz_cache[3+8* 2 + 2*8*i]= | ||
| 549 | nnz_cache[3+8* 6 + 2*8*i]= | ||
| 550 | nnz_cache[3+8* 7 + 2*8*i]= | ||
| 551 | nnz_cache[3+8*11 + 2*8*i]= | ||
| 552 | nnz_cache[3+8*12 + 2*8*i]= CABAC && !IS_INTRA(mb_type) ? 0 : 64; | ||
| 553 | } | 585 | } |
| 554 | } | ||
| 555 | 586 | ||
| 556 | if( CABAC ) { | 587 | if (CABAC) { |
| 557 | // top_cbp | 588 | // top_cbp |
| 558 | if(top_type) { | 589 | if (top_type) |
| 559 | h->top_cbp = h->cbp_table[top_xy]; | 590 | h->top_cbp = h->cbp_table[top_xy]; |
| 560 | } else { | 591 | else |
| 561 | h->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; | 592 | h->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; |
| 562 | } | 593 | // left_cbp |
| 563 | // left_cbp | 594 | if (left_type[LTOP]) { |
| 564 | if (left_type[LTOP]) { | 595 | h->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0) | |
| 565 | h->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0) | 596 | ((h->cbp_table[left_xy[LTOP]] >> (left_block[0] & (~1))) & 2) | |
| 566 | | ((h->cbp_table[left_xy[LTOP]]>>(left_block[0]&(~1)))&2) | 597 | (((h->cbp_table[left_xy[LBOT]] >> (left_block[2] & (~1))) & 2) << 2); |
| 567 | | (((h->cbp_table[left_xy[LBOT]]>>(left_block[2]&(~1)))&2) << 2); | 598 | } else { |
| 568 | } else { | 599 | h->left_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; |
| 569 | h->left_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; | 600 | } |
| 570 | } | 601 | } |
| 571 | } | 602 | } |
| 572 | } | ||
| 573 | 603 | ||
| 574 | if(IS_INTER(mb_type) || (IS_DIRECT(mb_type) && h->direct_spatial_mv_pred)){ | 604 | if (IS_INTER(mb_type) || (IS_DIRECT(mb_type) && h->direct_spatial_mv_pred)) { |
| 575 | int list; | 605 | int list; |
| 576 | int b_stride = h->b_stride; | 606 | int b_stride = h->b_stride; |
| 577 | for(list=0; list<h->list_count; list++){ | 607 | for (list = 0; list < h->list_count; list++) { |
| 578 | int8_t *ref_cache = &h->ref_cache[list][scan8[0]]; | 608 | int8_t *ref_cache = &h->ref_cache[list][scan8[0]]; |
| 579 | int8_t *ref = s->current_picture.f.ref_index[list]; | 609 | int8_t *ref = s->current_picture.f.ref_index[list]; |
| 580 | int16_t (*mv_cache)[2] = &h->mv_cache[list][scan8[0]]; | 610 | int16_t(*mv_cache)[2] = &h->mv_cache[list][scan8[0]]; |
| 581 | int16_t (*mv)[2] = s->current_picture.f.motion_val[list]; | 611 | int16_t(*mv)[2] = s->current_picture.f.motion_val[list]; |
| 582 | if(!USES_LIST(mb_type, list)){ | 612 | if (!USES_LIST(mb_type, list)) |
| 583 | continue; | 613 | continue; |
| 584 | } | ||
| 585 | assert(!(IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred)); | 614 | assert(!(IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred)); |
| 586 | 615 | ||
| 587 | if(USES_LIST(top_type, list)){ | 616 | if (USES_LIST(top_type, list)) { |
| 588 | const int b_xy= h->mb2b_xy[top_xy] + 3*b_stride; | 617 | const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride; |
| 589 | AV_COPY128(mv_cache[0 - 1*8], mv[b_xy + 0]); | 618 | AV_COPY128(mv_cache[0 - 1 * 8], mv[b_xy + 0]); |
| 590 | ref_cache[0 - 1*8]= | 619 | ref_cache[0 - 1 * 8] = |
| 591 | ref_cache[1 - 1*8]= ref[4*top_xy + 2]; | 620 | ref_cache[1 - 1 * 8] = ref[4 * top_xy + 2]; |
| 592 | ref_cache[2 - 1*8]= | 621 | ref_cache[2 - 1 * 8] = |
| 593 | ref_cache[3 - 1*8]= ref[4*top_xy + 3]; | 622 | ref_cache[3 - 1 * 8] = ref[4 * top_xy + 3]; |
| 594 | }else{ | 623 | } else { |
| 595 | AV_ZERO128(mv_cache[0 - 1*8]); | 624 | AV_ZERO128(mv_cache[0 - 1 * 8]); |
| 596 | AV_WN32A(&ref_cache[0 - 1*8], ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101u); | 625 | AV_WN32A(&ref_cache[0 - 1 * 8], |
| 626 | ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE) & 0xFF) * 0x01010101u); | ||
| 597 | } | 627 | } |
| 598 | 628 | ||
| 599 | if(mb_type & (MB_TYPE_16x8|MB_TYPE_8x8)){ | 629 | if (mb_type & (MB_TYPE_16x8 | MB_TYPE_8x8)) { |
| 600 | for(i=0; i<2; i++){ | 630 | for (i = 0; i < 2; i++) { |
| 601 | int cache_idx = -1 + i*2*8; | 631 | int cache_idx = -1 + i * 2 * 8; |
| 602 | if(USES_LIST(left_type[LEFT(i)], list)){ | 632 | if (USES_LIST(left_type[LEFT(i)], list)) { |
| 603 | const int b_xy= h->mb2b_xy[left_xy[LEFT(i)]] + 3; | 633 | const int b_xy = h->mb2b_xy[left_xy[LEFT(i)]] + 3; |
| 604 | const int b8_xy= 4*left_xy[LEFT(i)] + 1; | 634 | const int b8_xy = 4 * left_xy[LEFT(i)] + 1; |
| 605 | AV_COPY32(mv_cache[cache_idx ], mv[b_xy + b_stride*left_block[0+i*2]]); | 635 | AV_COPY32(mv_cache[cache_idx], |
| 606 | AV_COPY32(mv_cache[cache_idx+8], mv[b_xy + b_stride*left_block[1+i*2]]); | 636 | mv[b_xy + b_stride * left_block[0 + i * 2]]); |
| 607 | ref_cache[cache_idx ]= ref[b8_xy + (left_block[0+i*2]&~1)]; | 637 | AV_COPY32(mv_cache[cache_idx + 8], |
| 608 | ref_cache[cache_idx+8]= ref[b8_xy + (left_block[1+i*2]&~1)]; | 638 | mv[b_xy + b_stride * left_block[1 + i * 2]]); |
| 609 | }else{ | 639 | ref_cache[cache_idx] = ref[b8_xy + (left_block[0 + i * 2] & ~1)]; |
| 610 | AV_ZERO32(mv_cache[cache_idx ]); | 640 | ref_cache[cache_idx + 8] = ref[b8_xy + (left_block[1 + i * 2] & ~1)]; |
| 611 | AV_ZERO32(mv_cache[cache_idx+8]); | 641 | } else { |
| 612 | ref_cache[cache_idx ]= | 642 | AV_ZERO32(mv_cache[cache_idx]); |
| 613 | ref_cache[cache_idx+8]= (left_type[LEFT(i)]) ? LIST_NOT_USED : PART_NOT_AVAILABLE; | 643 | AV_ZERO32(mv_cache[cache_idx + 8]); |
| 644 | ref_cache[cache_idx] = | ||
| 645 | ref_cache[cache_idx + 8] = (left_type[LEFT(i)]) ? LIST_NOT_USED | ||
| 646 | : PART_NOT_AVAILABLE; | ||
| 647 | } | ||
| 614 | } | 648 | } |
| 615 | } | 649 | } else { |
| 616 | }else{ | 650 | if (USES_LIST(left_type[LTOP], list)) { |
| 617 | if(USES_LIST(left_type[LTOP], list)){ | 651 | const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3; |
| 618 | const int b_xy= h->mb2b_xy[left_xy[LTOP]] + 3; | 652 | const int b8_xy = 4 * left_xy[LTOP] + 1; |
| 619 | const int b8_xy= 4*left_xy[LTOP] + 1; | 653 | AV_COPY32(mv_cache[-1], mv[b_xy + b_stride * left_block[0]]); |
| 620 | AV_COPY32(mv_cache[-1], mv[b_xy + b_stride*left_block[0]]); | 654 | ref_cache[-1] = ref[b8_xy + (left_block[0] & ~1)]; |
| 621 | ref_cache[-1]= ref[b8_xy + (left_block[0]&~1)]; | 655 | } else { |
| 622 | }else{ | ||
| 623 | AV_ZERO32(mv_cache[-1]); | 656 | AV_ZERO32(mv_cache[-1]); |
| 624 | ref_cache[-1]= left_type[LTOP] ? LIST_NOT_USED : PART_NOT_AVAILABLE; | 657 | ref_cache[-1] = left_type[LTOP] ? LIST_NOT_USED |
| 658 | : PART_NOT_AVAILABLE; | ||
| 625 | } | 659 | } |
| 626 | } | 660 | } |
| 627 | 661 | ||
| 628 | if(USES_LIST(topright_type, list)){ | 662 | if (USES_LIST(topright_type, list)) { |
| 629 | const int b_xy= h->mb2b_xy[topright_xy] + 3*b_stride; | 663 | const int b_xy = h->mb2b_xy[topright_xy] + 3 * b_stride; |
| 630 | AV_COPY32(mv_cache[4 - 1*8], mv[b_xy]); | 664 | AV_COPY32(mv_cache[4 - 1 * 8], mv[b_xy]); |
| 631 | ref_cache[4 - 1*8]= ref[4*topright_xy + 2]; | 665 | ref_cache[4 - 1 * 8] = ref[4 * topright_xy + 2]; |
| 632 | }else{ | 666 | } else { |
| 633 | AV_ZERO32(mv_cache[4 - 1*8]); | 667 | AV_ZERO32(mv_cache[4 - 1 * 8]); |
| 634 | ref_cache[4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; | 668 | ref_cache[4 - 1 * 8] = topright_type ? LIST_NOT_USED |
| 669 | : PART_NOT_AVAILABLE; | ||
| 635 | } | 670 | } |
| 636 | if(ref_cache[2 - 1*8] < 0 || ref_cache[4 - 1*8] < 0){ | 671 | if(ref_cache[2 - 1*8] < 0 || ref_cache[4 - 1*8] < 0){ |
| 637 | if(USES_LIST(topleft_type, list)){ | 672 | if (USES_LIST(topleft_type, list)) { |
| 638 | const int b_xy = h->mb2b_xy[topleft_xy] + 3 + b_stride + (h->topleft_partition & 2*b_stride); | 673 | const int b_xy = h->mb2b_xy[topleft_xy] + 3 + b_stride + |
| 639 | const int b8_xy= 4*topleft_xy + 1 + (h->topleft_partition & 2); | 674 | (h->topleft_partition & 2 * b_stride); |
| 640 | AV_COPY32(mv_cache[-1 - 1*8], mv[b_xy]); | 675 | const int b8_xy = 4 * topleft_xy + 1 + (h->topleft_partition & 2); |
| 641 | ref_cache[-1 - 1*8]= ref[b8_xy]; | 676 | AV_COPY32(mv_cache[-1 - 1 * 8], mv[b_xy]); |
| 642 | }else{ | 677 | ref_cache[-1 - 1 * 8] = ref[b8_xy]; |
| 643 | AV_ZERO32(mv_cache[-1 - 1*8]); | 678 | } else { |
| 644 | ref_cache[-1 - 1*8]= topleft_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; | 679 | AV_ZERO32(mv_cache[-1 - 1 * 8]); |
| 680 | ref_cache[-1 - 1 * 8] = topleft_type ? LIST_NOT_USED | ||
| 681 | : PART_NOT_AVAILABLE; | ||
| 645 | } | 682 | } |
| 646 | } | 683 | } |
| 647 | 684 | ||
| 648 | if((mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2)) && !FRAME_MBAFF) | 685 | if ((mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2)) && !FRAME_MBAFF) |
| 649 | continue; | 686 | continue; |
| 650 | 687 | ||
| 651 | if(!(mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2))){ | 688 | if (!(mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2))) { |
| 652 | uint8_t (*mvd_cache)[2] = &h->mvd_cache[list][scan8[0]]; | 689 | uint8_t(*mvd_cache)[2] = &h->mvd_cache[list][scan8[0]]; |
| 653 | uint8_t (*mvd)[2] = h->mvd_table[list]; | 690 | uint8_t(*mvd)[2] = h->mvd_table[list]; |
| 654 | ref_cache[2+8*0] = | 691 | ref_cache[2 + 8 * 0] = |
| 655 | ref_cache[2+8*2] = PART_NOT_AVAILABLE; | 692 | ref_cache[2 + 8 * 2] = PART_NOT_AVAILABLE; |
| 656 | AV_ZERO32(mv_cache[2+8*0]); | 693 | AV_ZERO32(mv_cache[2 + 8 * 0]); |
| 657 | AV_ZERO32(mv_cache[2+8*2]); | 694 | AV_ZERO32(mv_cache[2 + 8 * 2]); |
| 658 | 695 | ||
| 659 | if( CABAC ) { | 696 | if (CABAC) { |
| 660 | if(USES_LIST(top_type, list)){ | 697 | if (USES_LIST(top_type, list)) { |
| 661 | const int b_xy= h->mb2br_xy[top_xy]; | 698 | const int b_xy = h->mb2br_xy[top_xy]; |
| 662 | AV_COPY64(mvd_cache[0 - 1*8], mvd[b_xy + 0]); | 699 | AV_COPY64(mvd_cache[0 - 1 * 8], mvd[b_xy + 0]); |
| 663 | }else{ | 700 | } else { |
| 664 | AV_ZERO64(mvd_cache[0 - 1*8]); | 701 | AV_ZERO64(mvd_cache[0 - 1 * 8]); |
| 665 | } | 702 | } |
| 666 | if(USES_LIST(left_type[LTOP], list)){ | 703 | if (USES_LIST(left_type[LTOP], list)) { |
| 667 | const int b_xy= h->mb2br_xy[left_xy[LTOP]] + 6; | 704 | const int b_xy = h->mb2br_xy[left_xy[LTOP]] + 6; |
| 668 | AV_COPY16(mvd_cache[-1 + 0*8], mvd[b_xy - left_block[0]]); | 705 | AV_COPY16(mvd_cache[-1 + 0 * 8], mvd[b_xy - left_block[0]]); |
| 669 | AV_COPY16(mvd_cache[-1 + 1*8], mvd[b_xy - left_block[1]]); | 706 | AV_COPY16(mvd_cache[-1 + 1 * 8], mvd[b_xy - left_block[1]]); |
| 670 | }else{ | 707 | } else { |
| 671 | AV_ZERO16(mvd_cache[-1 + 0*8]); | 708 | AV_ZERO16(mvd_cache[-1 + 0 * 8]); |
| 672 | AV_ZERO16(mvd_cache[-1 + 1*8]); | 709 | AV_ZERO16(mvd_cache[-1 + 1 * 8]); |
| 673 | } | 710 | } |
| 674 | if(USES_LIST(left_type[LBOT], list)){ | 711 | if (USES_LIST(left_type[LBOT], list)) { |
| 675 | const int b_xy= h->mb2br_xy[left_xy[LBOT]] + 6; | 712 | const int b_xy = h->mb2br_xy[left_xy[LBOT]] + 6; |
| 676 | AV_COPY16(mvd_cache[-1 + 2*8], mvd[b_xy - left_block[2]]); | 713 | AV_COPY16(mvd_cache[-1 + 2 * 8], mvd[b_xy - left_block[2]]); |
| 677 | AV_COPY16(mvd_cache[-1 + 3*8], mvd[b_xy - left_block[3]]); | 714 | AV_COPY16(mvd_cache[-1 + 3 * 8], mvd[b_xy - left_block[3]]); |
| 678 | }else{ | 715 | } else { |
| 679 | AV_ZERO16(mvd_cache[-1 + 2*8]); | 716 | AV_ZERO16(mvd_cache[-1 + 2 * 8]); |
| 680 | AV_ZERO16(mvd_cache[-1 + 3*8]); | 717 | AV_ZERO16(mvd_cache[-1 + 3 * 8]); |
| 681 | } | 718 | } |
| 682 | AV_ZERO16(mvd_cache[2+8*0]); | 719 | AV_ZERO16(mvd_cache[2 + 8 * 0]); |
| 683 | AV_ZERO16(mvd_cache[2+8*2]); | 720 | AV_ZERO16(mvd_cache[2 + 8 * 2]); |
| 684 | if(h->slice_type_nos == AV_PICTURE_TYPE_B){ | 721 | if (h->slice_type_nos == AV_PICTURE_TYPE_B) { |
| 685 | uint8_t *direct_cache = &h->direct_cache[scan8[0]]; | 722 | uint8_t *direct_cache = &h->direct_cache[scan8[0]]; |
| 686 | uint8_t *direct_table = h->direct_table; | 723 | uint8_t *direct_table = h->direct_table; |
| 687 | fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16>>1, 1); | 724 | fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16 >> 1, 1); |
| 688 | 725 | ||
| 689 | if(IS_DIRECT(top_type)){ | 726 | if (IS_DIRECT(top_type)) { |
| 690 | AV_WN32A(&direct_cache[-1*8], 0x01010101u*(MB_TYPE_DIRECT2>>1)); | 727 | AV_WN32A(&direct_cache[-1 * 8], |
| 691 | }else if(IS_8X8(top_type)){ | 728 | 0x01010101u * (MB_TYPE_DIRECT2 >> 1)); |
| 692 | int b8_xy = 4*top_xy; | 729 | } else if (IS_8X8(top_type)) { |
| 693 | direct_cache[0 - 1*8]= direct_table[b8_xy + 2]; | 730 | int b8_xy = 4 * top_xy; |
| 694 | direct_cache[2 - 1*8]= direct_table[b8_xy + 3]; | 731 | direct_cache[0 - 1 * 8] = direct_table[b8_xy + 2]; |
| 695 | }else{ | 732 | direct_cache[2 - 1 * 8] = direct_table[b8_xy + 3]; |
| 696 | AV_WN32A(&direct_cache[-1*8], 0x01010101*(MB_TYPE_16x16>>1)); | 733 | } else { |
| 734 | AV_WN32A(&direct_cache[-1 * 8], | ||
| 735 | 0x01010101 * (MB_TYPE_16x16 >> 1)); | ||
| 697 | } | 736 | } |
| 698 | 737 | ||
| 699 | if(IS_DIRECT(left_type[LTOP])) | 738 | if (IS_DIRECT(left_type[LTOP])) |
| 700 | direct_cache[-1 + 0*8]= MB_TYPE_DIRECT2>>1; | 739 | direct_cache[-1 + 0 * 8] = MB_TYPE_DIRECT2 >> 1; |
| 701 | else if(IS_8X8(left_type[LTOP])) | 740 | else if (IS_8X8(left_type[LTOP])) |
| 702 | direct_cache[-1 + 0*8]= direct_table[4*left_xy[LTOP] + 1 + (left_block[0]&~1)]; | 741 | direct_cache[-1 + 0 * 8] = direct_table[4 * left_xy[LTOP] + 1 + (left_block[0] & ~1)]; |
| 703 | else | 742 | else |
| 704 | direct_cache[-1 + 0*8]= MB_TYPE_16x16>>1; | 743 | direct_cache[-1 + 0 * 8] = MB_TYPE_16x16 >> 1; |
| 705 | 744 | ||
| 706 | if(IS_DIRECT(left_type[LBOT])) | 745 | if (IS_DIRECT(left_type[LBOT])) |
| 707 | direct_cache[-1 + 2*8]= MB_TYPE_DIRECT2>>1; | 746 | direct_cache[-1 + 2 * 8] = MB_TYPE_DIRECT2 >> 1; |
| 708 | else if(IS_8X8(left_type[LBOT])) | 747 | else if (IS_8X8(left_type[LBOT])) |
| 709 | direct_cache[-1 + 2*8]= direct_table[4*left_xy[LBOT] + 1 + (left_block[2]&~1)]; | 748 | direct_cache[-1 + 2 * 8] = direct_table[4 * left_xy[LBOT] + 1 + (left_block[2] & ~1)]; |
| 710 | else | 749 | else |
| 711 | direct_cache[-1 + 2*8]= MB_TYPE_16x16>>1; | 750 | direct_cache[-1 + 2 * 8] = MB_TYPE_16x16 >> 1; |
| 712 | } | 751 | } |
| 713 | } | 752 | } |
| 714 | } | 753 | } |
| 715 | if(FRAME_MBAFF){ | 754 | |
| 716 | #define MAP_MVS\ | 755 | #define MAP_MVS \ |
| 717 | MAP_F2F(scan8[0] - 1 - 1*8, topleft_type)\ | 756 | MAP_F2F(scan8[0] - 1 - 1 * 8, topleft_type) \ |
| 718 | MAP_F2F(scan8[0] + 0 - 1*8, top_type)\ | 757 | MAP_F2F(scan8[0] + 0 - 1 * 8, top_type) \ |
| 719 | MAP_F2F(scan8[0] + 1 - 1*8, top_type)\ | 758 | MAP_F2F(scan8[0] + 1 - 1 * 8, top_type) \ |
| 720 | MAP_F2F(scan8[0] + 2 - 1*8, top_type)\ | 759 | MAP_F2F(scan8[0] + 2 - 1 * 8, top_type) \ |
| 721 | MAP_F2F(scan8[0] + 3 - 1*8, top_type)\ | 760 | MAP_F2F(scan8[0] + 3 - 1 * 8, top_type) \ |
| 722 | MAP_F2F(scan8[0] + 4 - 1*8, topright_type)\ | 761 | MAP_F2F(scan8[0] + 4 - 1 * 8, topright_type) \ |
| 723 | MAP_F2F(scan8[0] - 1 + 0*8, left_type[LTOP])\ | 762 | MAP_F2F(scan8[0] - 1 + 0 * 8, left_type[LTOP]) \ |
| 724 | MAP_F2F(scan8[0] - 1 + 1*8, left_type[LTOP])\ | 763 | MAP_F2F(scan8[0] - 1 + 1 * 8, left_type[LTOP]) \ |
| 725 | MAP_F2F(scan8[0] - 1 + 2*8, left_type[LBOT])\ | 764 | MAP_F2F(scan8[0] - 1 + 2 * 8, left_type[LBOT]) \ |
| 726 | MAP_F2F(scan8[0] - 1 + 3*8, left_type[LBOT]) | 765 | MAP_F2F(scan8[0] - 1 + 3 * 8, left_type[LBOT]) |
| 727 | if(MB_FIELD){ | 766 | |
| 728 | #define MAP_F2F(idx, mb_type)\ | 767 | if (FRAME_MBAFF) { |
| 729 | if(!IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\ | 768 | if (MB_FIELD) { |
| 730 | h->ref_cache[list][idx] <<= 1;\ | 769 | |
| 731 | h->mv_cache[list][idx][1] /= 2;\ | 770 | #define MAP_F2F(idx, mb_type) \ |
| 732 | h->mvd_cache[list][idx][1] >>=1;\ | 771 | if (!IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0) { \ |
| 733 | } | 772 | h->ref_cache[list][idx] <<= 1; \ |
| 773 | h->mv_cache[list][idx][1] /= 2; \ | ||
| 774 | h->mvd_cache[list][idx][1] >>= 1; \ | ||
| 775 | } | ||
| 776 | |||
| 734 | MAP_MVS | 777 | MAP_MVS |
| 778 | } else { | ||
| 779 | |||
| 735 | #undef MAP_F2F | 780 | #undef MAP_F2F |
| 736 | }else{ | 781 | #define MAP_F2F(idx, mb_type) \ |
| 737 | #define MAP_F2F(idx, mb_type)\ | 782 | if (IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0) { \ |
| 738 | if(IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\ | 783 | h->ref_cache[list][idx] >>= 1; \ |
| 739 | h->ref_cache[list][idx] >>= 1;\ | 784 | h->mv_cache[list][idx][1] <<= 1; \ |
| 740 | h->mv_cache[list][idx][1] <<= 1;\ | 785 | h->mvd_cache[list][idx][1] <<= 1; \ |
| 741 | h->mvd_cache[list][idx][1] <<= 1;\ | 786 | } |
| 742 | } | 787 | |
| 743 | MAP_MVS | 788 | MAP_MVS |
| 744 | #undef MAP_F2F | 789 | #undef MAP_F2F |
| 745 | } | 790 | } |
| @@ -747,36 +792,34 @@ static void fill_decode_caches(H264Context *h, int mb_type){ · 1 unmodified line | |||
| 747 | } | 792 | } |
| 748 | } | 793 | } |
| 749 | 794 | ||
| 750 | h->neighbor_transform_size= !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[LTOP]); | 795 | h->neighbor_transform_size = !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[LTOP]); |
| 751 | } | 796 | } |
| 752 | 797 | ||
| 753 | /** | 798 | /** |
| 754 | * decodes a P_SKIP or B_SKIP macroblock | 799 | * decodes a P_SKIP or B_SKIP macroblock |
| 755 | */ | 800 | */ |
| 756 | static void av_unused decode_mb_skip(H264Context *h){ | 801 | static void av_unused decode_mb_skip(H264Context *h) |
| 757 | MpegEncContext * const s = &h->s; | 802 | { |
| 758 | const int mb_xy= h->mb_xy; | 803 | MpegEncContext *const s = &h->s; |
| 759 | int mb_type=0; | 804 | const int mb_xy = h->mb_xy; |
| 805 | int mb_type = 0; | ||
| 760 | 806 | ||
| 761 | memset(h->non_zero_count[mb_xy], 0, 48); | 807 | memset(h->non_zero_count[mb_xy], 0, 48); |
| 762 | 808 | ||
| 763 | if(MB_FIELD) | 809 | if (MB_FIELD) |
| 764 | mb_type|= MB_TYPE_INTERLACED; | 810 | mb_type |= MB_TYPE_INTERLACED; |
| 765 | 811 | ||
| 766 | if( h->slice_type_nos == AV_PICTURE_TYPE_B ) | 812 | if (h->slice_type_nos == AV_PICTURE_TYPE_B) { |
| 767 | { | ||
| 768 | // just for fill_caches. pred_direct_motion will set the real mb_type | 813 | // just for fill_caches. pred_direct_motion will set the real mb_type |
| 769 | mb_type|= MB_TYPE_L0L1|MB_TYPE_DIRECT2|MB_TYPE_SKIP; | 814 | mb_type |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 | MB_TYPE_SKIP; |
| 770 | if(h->direct_spatial_mv_pred){ | 815 | if (h->direct_spatial_mv_pred) { |
| 771 | fill_decode_neighbors(h, mb_type); | 816 | fill_decode_neighbors(h, mb_type); |
| 772 | fill_decode_caches(h, mb_type); //FIXME check what is needed and what not ... | 817 | fill_decode_caches(h, mb_type); //FIXME check what is needed and what not ... |
| 773 | } | 818 | } |
| 774 | ff_h264_pred_direct_motion(h, &mb_type); | 819 | ff_h264_pred_direct_motion(h, &mb_type); |
| 775 | mb_type|= MB_TYPE_SKIP; | 820 | mb_type |= MB_TYPE_SKIP; |
| 776 | } | 821 | } else { |
| 777 | else | 822 | mb_type |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_SKIP; |
| 778 | { | ||
| 779 | mb_type|= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_SKIP; | ||
| 780 | 823 | ||
| 781 | fill_decode_neighbors(h, mb_type); | 824 | fill_decode_neighbors(h, mb_type); |
| 782 | pred_pskip_motion(h); | 825 | pred_pskip_motion(h); |
| @@ -785,8 +828,8 @@ static void av_unused decode_mb_skip(H264Context *h){ · 2 unmodified lines | |||
| 785 | write_back_motion(h, mb_type); | 828 | write_back_motion(h, mb_type); |
| 786 | s->current_picture.f.mb_type[mb_xy] = mb_type; | 829 | s->current_picture.f.mb_type[mb_xy] = mb_type; |
| 787 | s->current_picture.f.qscale_table[mb_xy] = s->qscale; | 830 | s->current_picture.f.qscale_table[mb_xy] = s->qscale; |
| 788 | h->slice_table[ mb_xy ]= h->slice_num; | 831 | h->slice_table[mb_xy] = h->slice_num; |
| 789 | h->prev_mb_skipped= 1; | 832 | h->prev_mb_skipped = 1; |
| 790 | } | 833 | } |
| 791 | 834 | ||
| 792 | #endif /* AVCODEC_H264_MVPRED_H */ | 835 | #endif /* AVCODEC_H264_MVPRED_H */ |
| @@ -30,240 +30,243 @@ · 29 unmodified lines | |||
| 30 | #define AVCODEC_H264DATA_H | 30 | #define AVCODEC_H264DATA_H |
| 31 | 31 | ||
| 32 | #include <stdint.h> | 32 | #include <stdint.h> |
| 33 | |||
| 33 | #include "libavutil/rational.h" | 34 | #include "libavutil/rational.h" |
| 34 | #include "mpegvideo.h" | 35 | #include "mpegvideo.h" |
| 35 | #include "h264.h" | 36 | #include "h264.h" |
| 36 | 37 | ||
| 38 | static const uint8_t golomb_to_pict_type[5] = { | ||
| 39 | AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, AV_PICTURE_TYPE_I, | ||
| 40 | AV_PICTURE_TYPE_SP, AV_PICTURE_TYPE_SI | ||
| 41 | }; | ||
| 37 | 42 | ||
| 38 | static const uint8_t golomb_to_pict_type[5]= | 43 | static const uint8_t golomb_to_intra4x4_cbp[48] = { |
| 39 | {AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_SP, AV_PICTURE_TYPE_SI}; | 44 | 47, 31, 15, 0, 23, 27, 29, 30, 7, 11, 13, 14, 39, 43, 45, 46, |
| 40 | 45 | 16, 3, 5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44, 1, 2, 4, | |
| 41 | static const uint8_t golomb_to_intra4x4_cbp[48]={ | 46 | 8, 17, 18, 20, 24, 6, 9, 22, 25, 32, 33, 34, 36, 40, 38, 41 |
| 42 | 47, 31, 15, 0, 23, 27, 29, 30, 7, 11, 13, 14, 39, 43, 45, 46, | ||
| 43 | 16, 3, 5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44, 1, 2, 4, | ||
| 44 | 8, 17, 18, 20, 24, 6, 9, 22, 25, 32, 33, 34, 36, 40, 38, 41 | ||
| 45 | }; | 47 | }; |
| 46 | 48 | ||
| 47 | static const uint8_t golomb_to_inter_cbp[48]={ | 49 | static const uint8_t golomb_to_inter_cbp[48] = { |
| 48 | 0, 16, 1, 2, 4, 8, 32, 3, 5, 10, 12, 15, 47, 7, 11, 13, | 50 | 0, 16, 1, 2, 4, 8, 32, 3, 5, 10, 12, 15, 47, 7, 11, 13, |
| 49 | 14, 6, 9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46, | 51 | 14, 6, 9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46, |
| 50 | 17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41 | 52 | 17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41 |
| 51 | }; | 53 | }; |
| 52 | 54 | ||
| 53 | static const uint8_t zigzag_scan[16]={ | 55 | static const uint8_t zigzag_scan[16] = { |
| 54 | 0+0*4, 1+0*4, 0+1*4, 0+2*4, | 56 | 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, |
| 55 | 1+1*4, 2+0*4, 3+0*4, 2+1*4, | 57 | 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4, |
| 56 | 1+2*4, 0+3*4, 1+3*4, 2+2*4, | 58 | 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4, |
| 57 | 3+1*4, 3+2*4, 2+3*4, 3+3*4, | 59 | 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4, |
| 58 | }; | 60 | }; |
| 59 | 61 | ||
| 60 | static const uint8_t field_scan[16]={ | 62 | static const uint8_t field_scan[16] = { |
| 61 | 0+0*4, 0+1*4, 1+0*4, 0+2*4, | 63 | 0 + 0 * 4, 0 + 1 * 4, 1 + 0 * 4, 0 + 2 * 4, |
| 62 | 0+3*4, 1+1*4, 1+2*4, 1+3*4, | 64 | 0 + 3 * 4, 1 + 1 * 4, 1 + 2 * 4, 1 + 3 * 4, |
| 63 | 2+0*4, 2+1*4, 2+2*4, 2+3*4, | 65 | 2 + 0 * 4, 2 + 1 * 4, 2 + 2 * 4, 2 + 3 * 4, |
| 64 | 3+0*4, 3+1*4, 3+2*4, 3+3*4, | 66 | 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4, |
| 65 | }; | 67 | }; |
| 66 | 68 | ||
| 67 | static const uint8_t luma_dc_zigzag_scan[16]={ | 69 | static const uint8_t luma_dc_zigzag_scan[16] = { |
| 68 | 0*16 + 0*64, 1*16 + 0*64, 2*16 + 0*64, 0*16 + 2*64, | 70 | 0 * 16 + 0 * 64, 1 * 16 + 0 * 64, 2 * 16 + 0 * 64, 0 * 16 + 2 * 64, |
| 69 | 3*16 + 0*64, 0*16 + 1*64, 1*16 + 1*64, 2*16 + 1*64, | 71 | 3 * 16 + 0 * 64, 0 * 16 + 1 * 64, 1 * 16 + 1 * 64, 2 * 16 + 1 * 64, |
| 70 | 1*16 + 2*64, 2*16 + 2*64, 3*16 + 2*64, 0*16 + 3*64, | 72 | 1 * 16 + 2 * 64, 2 * 16 + 2 * 64, 3 * 16 + 2 * 64, 0 * 16 + 3 * 64, |
| 71 | 3*16 + 1*64, 1*16 + 3*64, 2*16 + 3*64, 3*16 + 3*64, | 73 | 3 * 16 + 1 * 64, 1 * 16 + 3 * 64, 2 * 16 + 3 * 64, 3 * 16 + 3 * 64, |
| 72 | }; | 74 | }; |
| 73 | 75 | ||
| 74 | static const uint8_t luma_dc_field_scan[16]={ | 76 | static const uint8_t luma_dc_field_scan[16] = { |
| 75 | 0*16 + 0*64, 2*16 + 0*64, 1*16 + 0*64, 0*16 + 2*64, | 77 | 0 * 16 + 0 * 64, 2 * 16 + 0 * 64, 1 * 16 + 0 * 64, 0 * 16 + 2 * 64, |
| 76 | 2*16 + 2*64, 3*16 + 0*64, 1*16 + 2*64, 3*16 + 2*64, | 78 | 2 * 16 + 2 * 64, 3 * 16 + 0 * 64, 1 * 16 + 2 * 64, 3 * 16 + 2 * 64, |
| 77 | 0*16 + 1*64, 2*16 + 1*64, 0*16 + 3*64, 2*16 + 3*64, | 79 | 0 * 16 + 1 * 64, 2 * 16 + 1 * 64, 0 * 16 + 3 * 64, 2 * 16 + 3 * 64, |
| 78 | 1*16 + 1*64, 3*16 + 1*64, 1*16 + 3*64, 3*16 + 3*64, | 80 | 1 * 16 + 1 * 64, 3 * 16 + 1 * 64, 1 * 16 + 3 * 64, 3 * 16 + 3 * 64, |
| 79 | }; | 81 | }; |
| 80 | 82 | ||
| 81 | static const uint8_t chroma_dc_scan[4]={ | 83 | static const uint8_t chroma_dc_scan[4] = { |
| 82 | (0+0*2)*16, (1+0*2)*16, | 84 | (0 + 0 * 2) * 16, (1 + 0 * 2) * 16, |
| 83 | (0+1*2)*16, (1+1*2)*16, | 85 | (0 + 1 * 2) * 16, (1 + 1 * 2) * 16, |
| 84 | }; | 86 | }; |
| 85 | 87 | ||
| 86 | static const uint8_t chroma422_dc_scan[8]={ | 88 | static const uint8_t chroma422_dc_scan[8] = { |
| 87 | (0+0*2)*16, (0+1*2)*16, | 89 | (0 + 0 * 2) * 16, (0 + 1 * 2) * 16, |
| 88 | (1+0*2)*16, (0+2*2)*16, | 90 | (1 + 0 * 2) * 16, (0 + 2 * 2) * 16, |
| 89 | (0+3*2)*16, (1+1*2)*16, | 91 | (0 + 3 * 2) * 16, (1 + 1 * 2) * 16, |
| 90 | (1+2*2)*16, (1+3*2)*16, | 92 | (1 + 2 * 2) * 16, (1 + 3 * 2) * 16, |
| 91 | }; | 93 | }; |
| 92 | 94 | ||
| 93 | // zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)] | 95 | // zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)] |
| 94 | static const uint8_t zigzag_scan8x8_cavlc[64]={ | 96 | static const uint8_t zigzag_scan8x8_cavlc[64] = { |
| 95 | 0+0*8, 1+1*8, 1+2*8, 2+2*8, | 97 | 0 + 0 * 8, 1 + 1 * 8, 1 + 2 * 8, 2 + 2 * 8, |
| 96 | 4+1*8, 0+5*8, 3+3*8, 7+0*8, | 98 | 4 + 1 * 8, 0 + 5 * 8, 3 + 3 * 8, 7 + 0 * 8, |
| 97 | 3+4*8, 1+7*8, 5+3*8, 6+3*8, | 99 | 3 + 4 * 8, 1 + 7 * 8, 5 + 3 * 8, 6 + 3 * 8, |
| 98 | 2+7*8, 6+4*8, 5+6*8, 7+5*8, | 100 | 2 + 7 * 8, 6 + 4 * 8, 5 + 6 * 8, 7 + 5 * 8, |
| 99 | 1+0*8, 2+0*8, 0+3*8, 3+1*8, | 101 | 1 + 0 * 8, 2 + 0 * 8, 0 + 3 * 8, 3 + 1 * 8, |
| 100 | 3+2*8, 0+6*8, 4+2*8, 6+1*8, | 102 | 3 + 2 * 8, 0 + 6 * 8, 4 + 2 * 8, 6 + 1 * 8, |
| 101 | 2+5*8, 2+6*8, 6+2*8, 5+4*8, | 103 | 2 + 5 * 8, 2 + 6 * 8, 6 + 2 * 8, 5 + 4 * 8, |
| 102 | 3+7*8, 7+3*8, 4+7*8, 7+6*8, | 104 | 3 + 7 * 8, 7 + 3 * 8, 4 + 7 * 8, 7 + 6 * 8, |
| 103 | 0+1*8, 3+0*8, 0+4*8, 4+0*8, | 105 | 0 + 1 * 8, 3 + 0 * 8, 0 + 4 * 8, 4 + 0 * 8, |
| 104 | 2+3*8, 1+5*8, 5+1*8, 5+2*8, | 106 | 2 + 3 * 8, 1 + 5 * 8, 5 + 1 * 8, 5 + 2 * 8, |
| 105 | 1+6*8, 3+5*8, 7+1*8, 4+5*8, | 107 | 1 + 6 * 8, 3 + 5 * 8, 7 + 1 * 8, 4 + 5 * 8, |
| 106 | 4+6*8, 7+4*8, 5+7*8, 6+7*8, | 108 | 4 + 6 * 8, 7 + 4 * 8, 5 + 7 * 8, 6 + 7 * 8, |
| 107 | 0+2*8, 2+1*8, 1+3*8, 5+0*8, | 109 | 0 + 2 * 8, 2 + 1 * 8, 1 + 3 * 8, 5 + 0 * 8, |
| 108 | 1+4*8, 2+4*8, 6+0*8, 4+3*8, | 110 | 1 + 4 * 8, 2 + 4 * 8, 6 + 0 * 8, 4 + 3 * 8, |
| 109 | 0+7*8, 4+4*8, 7+2*8, 3+6*8, | 111 | 0 + 7 * 8, 4 + 4 * 8, 7 + 2 * 8, 3 + 6 * 8, |
| 110 | 5+5*8, 6+5*8, 6+6*8, 7+7*8, | 112 | 5 + 5 * 8, 6 + 5 * 8, 6 + 6 * 8, 7 + 7 * 8, |
| 111 | }; | 113 | }; |
| 112 | 114 | ||
| 113 | static const uint8_t field_scan8x8[64]={ | 115 | static const uint8_t field_scan8x8[64] = { |
| 114 | 0+0*8, 0+1*8, 0+2*8, 1+0*8, | 116 | 0 + 0 * 8, 0 + 1 * 8, 0 + 2 * 8, 1 + 0 * 8, |
| 115 | 1+1*8, 0+3*8, 0+4*8, 1+2*8, | 117 | 1 + 1 * 8, 0 + 3 * 8, 0 + 4 * 8, 1 + 2 * 8, |
| 116 | 2+0*8, 1+3*8, 0+5*8, 0+6*8, | 118 | 2 + 0 * 8, 1 + 3 * 8, 0 + 5 * 8, 0 + 6 * 8, |
| 117 | 0+7*8, 1+4*8, 2+1*8, 3+0*8, | 119 | 0 + 7 * 8, 1 + 4 * 8, 2 + 1 * 8, 3 + 0 * 8, |
| 118 | 2+2*8, 1+5*8, 1+6*8, 1+7*8, | 120 | 2 + 2 * 8, 1 + 5 * 8, 1 + 6 * 8, 1 + 7 * 8, |
| 119 | 2+3*8, 3+1*8, 4+0*8, 3+2*8, | 121 | 2 + 3 * 8, 3 + 1 * 8, 4 + 0 * 8, 3 + 2 * 8, |
| 120 | 2+4*8, 2+5*8, 2+6*8, 2+7*8, | 122 | 2 + 4 * 8, 2 + 5 * 8, 2 + 6 * 8, 2 + 7 * 8, |
| 121 | 3+3*8, 4+1*8, 5+0*8, 4+2*8, | 123 | 3 + 3 * 8, 4 + 1 * 8, 5 + 0 * 8, 4 + 2 * 8, |
| 122 | 3+4*8, 3+5*8, 3+6*8, 3+7*8, | 124 | 3 + 4 * 8, 3 + 5 * 8, 3 + 6 * 8, 3 + 7 * 8, |
| 123 | 4+3*8, 5+1*8, 6+0*8, 5+2*8, | 125 | 4 + 3 * 8, 5 + 1 * 8, 6 + 0 * 8, 5 + 2 * 8, |
| 124 | 4+4*8, 4+5*8, 4+6*8, 4+7*8, | 126 | 4 + 4 * 8, 4 + 5 * 8, 4 + 6 * 8, 4 + 7 * 8, |
| 125 | 5+3*8, 6+1*8, 6+2*8, 5+4*8, | 127 | 5 + 3 * 8, 6 + 1 * 8, 6 + 2 * 8, 5 + 4 * 8, |
| 126 | 5+5*8, 5+6*8, 5+7*8, 6+3*8, | 128 | 5 + 5 * 8, 5 + 6 * 8, 5 + 7 * 8, 6 + 3 * 8, |
| 127 | 7+0*8, 7+1*8, 6+4*8, 6+5*8, | 129 | 7 + 0 * 8, 7 + 1 * 8, 6 + 4 * 8, 6 + 5 * 8, |
| 128 | 6+6*8, 6+7*8, 7+2*8, 7+3*8, | 130 | 6 + 6 * 8, 6 + 7 * 8, 7 + 2 * 8, 7 + 3 * 8, |
| 129 | 7+4*8, 7+5*8, 7+6*8, 7+7*8, | 131 | 7 + 4 * 8, 7 + 5 * 8, 7 + 6 * 8, 7 + 7 * 8, |
| 130 | }; | 132 | }; |
| 131 | 133 | ||
| 132 | static const uint8_t field_scan8x8_cavlc[64]={ | 134 | static const uint8_t field_scan8x8_cavlc[64] = { |
| 133 | 0+0*8, 1+1*8, 2+0*8, 0+7*8, | 135 | 0 + 0 * 8, 1 + 1 * 8, 2 + 0 * 8, 0 + 7 * 8, |
| 134 | 2+2*8, 2+3*8, 2+4*8, 3+3*8, | 136 | 2 + 2 * 8, 2 + 3 * 8, 2 + 4 * 8, 3 + 3 * 8, |
| 135 | 3+4*8, 4+3*8, 4+4*8, 5+3*8, | 137 | 3 + 4 * 8, 4 + 3 * 8, 4 + 4 * 8, 5 + 3 * 8, |
| 136 | 5+5*8, 7+0*8, 6+6*8, 7+4*8, | 138 | 5 + 5 * 8, 7 + 0 * 8, 6 + 6 * 8, 7 + 4 * 8, |
| 137 | 0+1*8, 0+3*8, 1+3*8, 1+4*8, | 139 | 0 + 1 * 8, 0 + 3 * 8, 1 + 3 * 8, 1 + 4 * 8, |
| 138 | 1+5*8, 3+1*8, 2+5*8, 4+1*8, | 140 | 1 + 5 * 8, 3 + 1 * 8, 2 + 5 * 8, 4 + 1 * 8, |
| 139 | 3+5*8, 5+1*8, 4+5*8, 6+1*8, | 141 | 3 + 5 * 8, 5 + 1 * 8, 4 + 5 * 8, 6 + 1 * 8, |
| 140 | 5+6*8, 7+1*8, 6+7*8, 7+5*8, | 142 | 5 + 6 * 8, 7 + 1 * 8, 6 + 7 * 8, 7 + 5 * 8, |
| 141 | 0+2*8, 0+4*8, 0+5*8, 2+1*8, | 143 | 0 + 2 * 8, 0 + 4 * 8, 0 + 5 * 8, 2 + 1 * 8, |
| 142 | 1+6*8, 4+0*8, 2+6*8, 5+0*8, | 144 | 1 + 6 * 8, 4 + 0 * 8, 2 + 6 * 8, 5 + 0 * 8, |
| 143 | 3+6*8, 6+0*8, 4+6*8, 6+2*8, | 145 | 3 + 6 * 8, 6 + 0 * 8, 4 + 6 * 8, 6 + 2 * 8, |
| 144 | 5+7*8, 6+4*8, 7+2*8, 7+6*8, | 146 | 5 + 7 * 8, 6 + 4 * 8, 7 + 2 * 8, 7 + 6 * 8, |
| 145 | 1+0*8, 1+2*8, 0+6*8, 3+0*8, | 147 | 1 + 0 * 8, 1 + 2 * 8, 0 + 6 * 8, 3 + 0 * 8, |
| 146 | 1+7*8, 3+2*8, 2+7*8, 4+2*8, | 148 | 1 + 7 * 8, 3 + 2 * 8, 2 + 7 * 8, 4 + 2 * 8, |
| 147 | 3+7*8, 5+2*8, 4+7*8, 5+4*8, | 149 | 3 + 7 * 8, 5 + 2 * 8, 4 + 7 * 8, 5 + 4 * 8, |
| 148 | 6+3*8, 6+5*8, 7+3*8, 7+7*8, | 150 | 6 + 3 * 8, 6 + 5 * 8, 7 + 3 * 8, 7 + 7 * 8, |
| 149 | }; | 151 | }; |
| 150 | 152 | ||
| 151 | typedef struct IMbInfo{ | 153 | typedef struct IMbInfo { |
| 152 | uint16_t type; | 154 | uint16_t type; |
| 153 | uint8_t pred_mode; | 155 | uint8_t pred_mode; |
| 154 | uint8_t cbp; | 156 | uint8_t cbp; |
| 155 | } IMbInfo; | 157 | } IMbInfo; |
| 156 | 158 | ||
| 157 | static const IMbInfo i_mb_type_info[26]={ | 159 | static const IMbInfo i_mb_type_info[26] = { |
| 158 | {MB_TYPE_INTRA4x4 , -1, -1}, | 160 | { MB_TYPE_INTRA4x4, -1, -1 }, |
| 159 | {MB_TYPE_INTRA16x16, 2, 0}, | 161 | { MB_TYPE_INTRA16x16, 2, 0 }, |
| 160 | {MB_TYPE_INTRA16x16, 1, 0}, | 162 | { MB_TYPE_INTRA16x16, 1, 0 }, |
| 161 | {MB_TYPE_INTRA16x16, 0, 0}, | 163 | { MB_TYPE_INTRA16x16, 0, 0 }, |
| 162 | {MB_TYPE_INTRA16x16, 3, 0}, | 164 | { MB_TYPE_INTRA16x16, 3, 0 }, |
| 163 | {MB_TYPE_INTRA16x16, 2, 16}, | 165 | { MB_TYPE_INTRA16x16, 2, 16 }, |
| 164 | {MB_TYPE_INTRA16x16, 1, 16}, | 166 | { MB_TYPE_INTRA16x16, 1, 16 }, |
| 165 | {MB_TYPE_INTRA16x16, 0, 16}, | 167 | { MB_TYPE_INTRA16x16, 0, 16 }, |
| 166 | {MB_TYPE_INTRA16x16, 3, 16}, | 168 | { MB_TYPE_INTRA16x16, 3, 16 }, |
| 167 | {MB_TYPE_INTRA16x16, 2, 32}, | 169 | { MB_TYPE_INTRA16x16, 2, 32 }, |
| 168 | {MB_TYPE_INTRA16x16, 1, 32}, | 170 | { MB_TYPE_INTRA16x16, 1, 32 }, |
| 169 | {MB_TYPE_INTRA16x16, 0, 32}, | 171 | { MB_TYPE_INTRA16x16, 0, 32 }, |
| 170 | {MB_TYPE_INTRA16x16, 3, 32}, | 172 | { MB_TYPE_INTRA16x16, 3, 32 }, |
| 171 | {MB_TYPE_INTRA16x16, 2, 15+0}, | 173 | { MB_TYPE_INTRA16x16, 2, 15 + 0 }, |
| 172 | {MB_TYPE_INTRA16x16, 1, 15+0}, | 174 | { MB_TYPE_INTRA16x16, 1, 15 + 0 }, |
| 173 | {MB_TYPE_INTRA16x16, 0, 15+0}, | 175 | { MB_TYPE_INTRA16x16, 0, 15 + 0 }, |
| 174 | {MB_TYPE_INTRA16x16, 3, 15+0}, | 176 | { MB_TYPE_INTRA16x16, 3, 15 + 0 }, |
| 175 | {MB_TYPE_INTRA16x16, 2, 15+16}, | 177 | { MB_TYPE_INTRA16x16, 2, 15 + 16 }, |
| 176 | {MB_TYPE_INTRA16x16, 1, 15+16}, | 178 | { MB_TYPE_INTRA16x16, 1, 15 + 16 }, |
| 177 | {MB_TYPE_INTRA16x16, 0, 15+16}, | 179 | { MB_TYPE_INTRA16x16, 0, 15 + 16 }, |
| 178 | {MB_TYPE_INTRA16x16, 3, 15+16}, | 180 | { MB_TYPE_INTRA16x16, 3, 15 + 16 }, |
| 179 | {MB_TYPE_INTRA16x16, 2, 15+32}, | 181 | { MB_TYPE_INTRA16x16, 2, 15 + 32 }, |
| 180 | {MB_TYPE_INTRA16x16, 1, 15+32}, | 182 | { MB_TYPE_INTRA16x16, 1, 15 + 32 }, |
| 181 | {MB_TYPE_INTRA16x16, 0, 15+32}, | 183 | { MB_TYPE_INTRA16x16, 0, 15 + 32 }, |
| 182 | {MB_TYPE_INTRA16x16, 3, 15+32}, | 184 | { MB_TYPE_INTRA16x16, 3, 15 + 32 }, |
| 183 | {MB_TYPE_INTRA_PCM , -1, -1}, | 185 | { MB_TYPE_INTRA_PCM, -1, -1 }, |
| 184 | }; | 186 | }; |
| 185 | 187 | ||
| 186 | typedef struct PMbInfo{ | 188 | typedef struct PMbInfo { |
| 187 | uint16_t type; | 189 | uint16_t type; |
| 188 | uint8_t partition_count; | 190 | uint8_t partition_count; |
| 189 | } PMbInfo; | 191 | } PMbInfo; |
| 190 | 192 | ||
| 191 | static const PMbInfo p_mb_type_info[5]={ | 193 | static const PMbInfo p_mb_type_info[5] = { |
| 192 | {MB_TYPE_16x16|MB_TYPE_P0L0 , 1}, | 194 | { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 }, |
| 193 | {MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P1L0, 2}, | 195 | { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 }, |
| 194 | {MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P1L0, 2}, | 196 | { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 }, |
| 195 | {MB_TYPE_8x8 |MB_TYPE_P0L0|MB_TYPE_P1L0, 4}, | 197 | { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4 }, |
| 196 | {MB_TYPE_8x8 |MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_REF0, 4}, | 198 | { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_REF0, 4 }, |
| 197 | }; | 199 | }; |
| 198 | 200 | ||
| 199 | static const PMbInfo p_sub_mb_type_info[4]={ | 201 | static const PMbInfo p_sub_mb_type_info[4] = { |
| 200 | {MB_TYPE_16x16|MB_TYPE_P0L0 , 1}, | 202 | { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 }, |
| 201 | {MB_TYPE_16x8 |MB_TYPE_P0L0 , 2}, | 203 | { MB_TYPE_16x8 | MB_TYPE_P0L0, 2 }, |
| 202 | {MB_TYPE_8x16 |MB_TYPE_P0L0 , 2}, | 204 | { MB_TYPE_8x16 | MB_TYPE_P0L0, 2 }, |
| 203 | {MB_TYPE_8x8 |MB_TYPE_P0L0 , 4}, | 205 | { MB_TYPE_8x8 | MB_TYPE_P0L0, 4 }, |
| 204 | }; | 206 | }; |
| 205 | 207 | ||
| 206 | static const PMbInfo b_mb_type_info[23]={ | 208 | static const PMbInfo b_mb_type_info[23] = { |
| 207 | {MB_TYPE_DIRECT2|MB_TYPE_L0L1 , 1, }, | 209 | { MB_TYPE_DIRECT2 | MB_TYPE_L0L1, 1, }, |
| 208 | {MB_TYPE_16x16|MB_TYPE_P0L0 , 1, }, | 210 | { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, }, |
| 209 | {MB_TYPE_16x16 |MB_TYPE_P0L1 , 1, }, | 211 | { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, }, |
| 210 | {MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1 , 1, }, | 212 | { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, }, |
| 211 | {MB_TYPE_16x8 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 2, }, | 213 | { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, }, |
| 212 | {MB_TYPE_8x16 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 2, }, | 214 | { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, }, |
| 213 | {MB_TYPE_16x8 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | 215 | { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, |
| 214 | {MB_TYPE_8x16 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | 216 | { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, |
| 215 | {MB_TYPE_16x8 |MB_TYPE_P0L0 |MB_TYPE_P1L1, 2, }, | 217 | { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, }, |
| 216 | {MB_TYPE_8x16 |MB_TYPE_P0L0 |MB_TYPE_P1L1, 2, }, | 218 | { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, }, |
| 217 | {MB_TYPE_16x8 |MB_TYPE_P0L1|MB_TYPE_P1L0 , 2, }, | 219 | { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, }, |
| 218 | {MB_TYPE_8x16 |MB_TYPE_P0L1|MB_TYPE_P1L0 , 2, }, | 220 | { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, }, |
| 219 | {MB_TYPE_16x8 |MB_TYPE_P0L0 |MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | 221 | { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, |
| 220 | {MB_TYPE_8x16 |MB_TYPE_P0L0 |MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | 222 | { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, |
| 221 | {MB_TYPE_16x8 |MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | 223 | { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, |
| 222 | {MB_TYPE_8x16 |MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | 224 | { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, |
| 223 | {MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0 , 2, }, | 225 | { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, }, |
| 224 | {MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0 , 2, }, | 226 | { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, }, |
| 225 | {MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | 227 | { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, |
| 226 | {MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | 228 | { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, |
| 227 | {MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | 229 | { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, |
| 228 | {MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | 230 | { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, |
| 229 | {MB_TYPE_8x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 4, }, | 231 | { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 4, }, |
| 230 | }; | 232 | }; |
| 231 | 233 | ||
| 232 | static const PMbInfo b_sub_mb_type_info[13]={ | 234 | static const PMbInfo b_sub_mb_type_info[13] = { |
| 233 | {MB_TYPE_DIRECT2 , 1, }, | 235 | { MB_TYPE_DIRECT2, 1, }, |
| 234 | {MB_TYPE_16x16|MB_TYPE_P0L0 , 1, }, | 236 | { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, }, |
| 235 | {MB_TYPE_16x16 |MB_TYPE_P0L1 , 1, }, | 237 | { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, }, |
| 236 | {MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1 , 1, }, | 238 | { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, }, |
| 237 | {MB_TYPE_16x8 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 2, }, | 239 | { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, }, |
| 238 | {MB_TYPE_8x16 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 2, }, | 240 | { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, }, |
| 239 | {MB_TYPE_16x8 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | 241 | { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, |
| 240 | {MB_TYPE_8x16 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | 242 | { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, |
| 241 | {MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | 243 | { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, |
| 242 | {MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | 244 | { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, |
| 243 | {MB_TYPE_8x8 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 4, }, | 245 | { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4, }, |
| 244 | {MB_TYPE_8x8 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 4, }, | 246 | { MB_TYPE_8x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 4, }, |
| 245 | {MB_TYPE_8x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 4, }, | 247 | { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 4, }, |
| 246 | }; | 248 | }; |
| 247 | 249 | ||
| 248 | static const uint8_t dequant4_coeff_init[6][3]={ | 250 | static const uint8_t dequant4_coeff_init[6][3] = { |
| 249 | {10,13,16}, | 251 | { 10, 13, 16 }, |
| 250 | {11,14,18}, | 252 | { 11, 14, 18 }, |
| 251 | {13,16,20}, | 253 | { 13, 16, 20 }, |
| 252 | {14,18,23}, | 254 | { 14, 18, 23 }, |
| 253 | {16,20,25}, | 255 | { 16, 20, 25 }, |
| 254 | {18,23,29}, | 256 | { 18, 23, 29 }, |
| 255 | }; | 257 | }; |
| 256 | 258 | ||
| 257 | static const uint8_t dequant8_coeff_init_scan[16] = { | 259 | static const uint8_t dequant8_coeff_init_scan[16] = { |
| 258 | 0,3,4,3, 3,1,5,1, 4,5,2,5, 3,1,5,1 | 260 | 0, 3, 4, 3, 3, 1, 5, 1, 4, 5, 2, 5, 3, 1, 5, 1 |
| 259 | }; | 261 | }; |
| 260 | static const uint8_t dequant8_coeff_init[6][6]={ | 262 | |
| 261 | {20,18,32,19,25,24}, | 263 | static const uint8_t dequant8_coeff_init[6][6] = { |
| 262 | {22,19,35,21,28,26}, | 264 | { 20, 18, 32, 19, 25, 24 }, |
| 263 | {26,23,42,24,33,31}, | 265 | { 22, 19, 35, 21, 28, 26 }, |
| 264 | {28,25,45,26,35,33}, | 266 | { 26, 23, 42, 24, 33, 31 }, |
| 265 | {32,28,51,30,40,38}, | 267 | { 28, 25, 45, 26, 35, 33 }, |
| 266 | {36,32,58,34,46,43}, | 268 | { 32, 28, 51, 30, 40, 38 }, |
| 269 | { 36, 32, 58, 34, 46, 43 }, | ||
| 267 | }; | 270 | }; |
| 268 | 271 | ||
| 269 | #endif /* AVCODEC_H264DATA_H */ | 272 | #endif /* AVCODEC_H264DATA_H */ |
| @@ -28,56 +28,90 @@ · 27 unmodified lines | |||
| 28 | #define AVCODEC_H264DSP_H | 28 | #define AVCODEC_H264DSP_H |
| 29 | 29 | ||
| 30 | #include <stdint.h> | 30 | #include <stdint.h> |
| 31 | |||
| 31 | #include "dsputil.h" | 32 | #include "dsputil.h" |
| 32 | 33 | ||
| 33 | typedef void (*h264_weight_func)(uint8_t *block, int stride, int height, | 34 | typedef void (*h264_weight_func)(uint8_t *block, int stride, int height, |
| 34 | int log2_denom, int weight, int offset); | 35 | int log2_denom, int weight, int offset); |
| 35 | typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int height, | 36 | typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, |
| 36 | int log2_denom, int weightd, int weights, int offset); | 37 | int stride, int height, int log2_denom, |
| 38 | int weightd, int weights, int offset); | ||
| 37 | 39 | ||
| 38 | /** | 40 | /** |
| 39 | * Context for storing H.264 DSP functions | 41 | * Context for storing H.264 DSP functions |
| 40 | */ | 42 | */ |
| 41 | typedef struct H264DSPContext{ | 43 | typedef struct H264DSPContext { |
| 42 | /* weighted MC */ | 44 | /* weighted MC */ |
| 43 | h264_weight_func weight_h264_pixels_tab[4]; | 45 | h264_weight_func weight_h264_pixels_tab[4]; |
| 44 | h264_biweight_func biweight_h264_pixels_tab[4]; | 46 | h264_biweight_func biweight_h264_pixels_tab[4]; |
| 45 | 47 | ||
| 46 | /* loop filter */ | 48 | /* loop filter */ |
| 47 | void (*h264_v_loop_filter_luma)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta, int8_t *tc0); | 49 | void (*h264_v_loop_filter_luma)(uint8_t *pix /*align 16*/, int stride, |
| 48 | void (*h264_h_loop_filter_luma)(uint8_t *pix/*align 4 */, int stride, int alpha, int beta, int8_t *tc0); | 50 | int alpha, int beta, int8_t *tc0); |
| 49 | void (*h264_h_loop_filter_luma_mbaff)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta, int8_t *tc0); | 51 | void (*h264_h_loop_filter_luma)(uint8_t *pix /*align 4 */, int stride, |
| 52 | int alpha, int beta, int8_t *tc0); | ||
| 53 | void (*h264_h_loop_filter_luma_mbaff)(uint8_t *pix /*align 16*/, int stride, | ||
| 54 | int alpha, int beta, int8_t *tc0); | ||
| 50 | /* v/h_loop_filter_luma_intra: align 16 */ | 55 | /* v/h_loop_filter_luma_intra: align 16 */ |
| 51 | void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta); | 56 | void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride, |
| 52 | void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta); | 57 | int alpha, int beta); |
| 53 | void (*h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta); | 58 | void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride, |
| 54 | void (*h264_v_loop_filter_chroma)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta, int8_t *tc0); | 59 | int alpha, int beta); |
| 55 | void (*h264_h_loop_filter_chroma)(uint8_t *pix/*align 4*/, int stride, int alpha, int beta, int8_t *tc0); | 60 | void (*h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix /*align 16*/, |
| 56 | void (*h264_h_loop_filter_chroma_mbaff)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta, int8_t *tc0); | 61 | int stride, int alpha, int beta); |
| 57 | void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta); | 62 | void (*h264_v_loop_filter_chroma)(uint8_t *pix /*align 8*/, int stride, |
| 58 | void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta); | 63 | int alpha, int beta, int8_t *tc0); |
| 59 | void (*h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta); | 64 | void (*h264_h_loop_filter_chroma)(uint8_t *pix /*align 4*/, int stride, |
| 65 | int alpha, int beta, int8_t *tc0); | ||
| 66 | void (*h264_h_loop_filter_chroma_mbaff)(uint8_t *pix /*align 8*/, | ||
| 67 | int stride, int alpha, int beta, | ||
| 68 | int8_t *tc0); | ||
| 69 | void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix /*align 8*/, | ||
| 70 | int stride, int alpha, int beta); | ||
| 71 | void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix /*align 8*/, | ||
| 72 | int stride, int alpha, int beta); | ||
| 73 | void (*h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix /*align 8*/, | ||
| 74 | int stride, int alpha, int beta); | ||
| 60 | // h264_loop_filter_strength: simd only. the C version is inlined in h264.c | 75 | // h264_loop_filter_strength: simd only. the C version is inlined in h264.c |
| 61 | void (*h264_loop_filter_strength)(int16_t bS[2][4][4], uint8_t nnz[40], int8_t ref[2][40], int16_t mv[2][40][2], | 76 | void (*h264_loop_filter_strength)(int16_t bS[2][4][4], uint8_t nnz[40], |
| 62 | int bidir, int edges, int step, int mask_mv0, int mask_mv1, int field); | 77 | int8_t ref[2][40], int16_t mv[2][40][2], |
| 78 | int bidir, int edges, int step, | ||
| 79 | int mask_mv0, int mask_mv1, int field); | ||
| 63 | 80 | ||
| 64 | /* IDCT */ | 81 | /* IDCT */ |
| 65 | void (*h264_idct_add)(uint8_t *dst/*align 4*/, DCTELEM *block/*align 16*/, int stride); | 82 | void (*h264_idct_add)(uint8_t *dst /*align 4*/, |
| 66 | void (*h264_idct8_add)(uint8_t *dst/*align 8*/, DCTELEM *block/*align 16*/, int stride); | 83 | DCTELEM *block /*align 16*/, int stride); |
| 67 | void (*h264_idct_dc_add)(uint8_t *dst/*align 4*/, DCTELEM *block/*align 16*/, int stride); | 84 | void (*h264_idct8_add)(uint8_t *dst /*align 8*/, |
| 68 | void (*h264_idct8_dc_add)(uint8_t *dst/*align 8*/, DCTELEM *block/*align 16*/, int stride); | 85 | DCTELEM *block /*align 16*/, int stride); |
| 86 | void (*h264_idct_dc_add)(uint8_t *dst /*align 4*/, | ||
| 87 | DCTELEM *block /*align 16*/, int stride); | ||
| 88 | void (*h264_idct8_dc_add)(uint8_t *dst /*align 8*/, | ||
| 89 | DCTELEM *block /*align 16*/, int stride); | ||
| 69 | 90 | ||
| 70 | void (*h264_idct_add16)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[15*8]); | 91 | void (*h264_idct_add16)(uint8_t *dst /*align 16*/, const int *blockoffset, |
| 71 | void (*h264_idct8_add4)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[15*8]); | 92 | DCTELEM *block /*align 16*/, int stride, |
| 72 | void (*h264_idct_add8)(uint8_t **dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[15*8]); | 93 | const uint8_t nnzc[15 * 8]); |
| 73 | void (*h264_idct_add16intra)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[15*8]); | 94 | void (*h264_idct8_add4)(uint8_t *dst /*align 16*/, const int *blockoffset, |
| 74 | void (*h264_luma_dc_dequant_idct)(DCTELEM *output, DCTELEM *input/*align 16*/, int qmul); | 95 | DCTELEM *block /*align 16*/, int stride, |
| 96 | const uint8_t nnzc[15 * 8]); | ||
| 97 | void (*h264_idct_add8)(uint8_t **dst /*align 16*/, const int *blockoffset, | ||
| 98 | DCTELEM *block /*align 16*/, int stride, | ||
| 99 | const uint8_t nnzc[15 * 8]); | ||
| 100 | void (*h264_idct_add16intra)(uint8_t *dst /*align 16*/, const int *blockoffset, | ||
| 101 | DCTELEM *block /*align 16*/, | ||
| 102 | int stride, const uint8_t nnzc[15 * 8]); | ||
| 103 | void (*h264_luma_dc_dequant_idct)(DCTELEM *output, | ||
| 104 | DCTELEM *input /*align 16*/, int qmul); | ||
| 75 | void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul); | 105 | void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul); |
| 76 | }H264DSPContext; | 106 | } H264DSPContext; |
| 77 | 107 | ||
| 78 | void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); | 108 | void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, |
| 79 | void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); | 109 | const int chroma_format_idc); |
| 80 | void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); | 110 | void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, |
| 81 | void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); | 111 | const int chroma_format_idc); |
| 112 | void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth, | ||
| 113 | const int chroma_format_idc); | ||
| 114 | void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, | ||
| 115 | const int chroma_format_idc); | ||
| 82 | 116 | ||
| 83 | #endif /* AVCODEC_H264DSP_H */ | 117 | #endif /* AVCODEC_H264DSP_H */ |
| @@ -35,18 +35,18 @@ · 34 unmodified lines | |||
| 35 | * Prediction types | 35 | * Prediction types |
| 36 | */ | 36 | */ |
| 37 | //@{ | 37 | //@{ |
| 38 | #define VERT_PRED 0 | 38 | #define VERT_PRED 0 |
| 39 | #define HOR_PRED 1 | 39 | #define HOR_PRED 1 |
| 40 | #define DC_PRED 2 | 40 | #define DC_PRED 2 |
| 41 | #define DIAG_DOWN_LEFT_PRED 3 | 41 | #define DIAG_DOWN_LEFT_PRED 3 |
| 42 | #define DIAG_DOWN_RIGHT_PRED 4 | 42 | #define DIAG_DOWN_RIGHT_PRED 4 |
| 43 | #define VERT_RIGHT_PRED 5 | 43 | #define VERT_RIGHT_PRED 5 |
| 44 | #define HOR_DOWN_PRED 6 | 44 | #define HOR_DOWN_PRED 6 |
| 45 | #define VERT_LEFT_PRED 7 | 45 | #define VERT_LEFT_PRED 7 |
| 46 | #define HOR_UP_PRED 8 | 46 | #define HOR_UP_PRED 8 |
| 47 | 47 | ||
| 48 | // DC edge (not for VP8) | 48 | // DC edge (not for VP8) |
| 49 | #define LEFT_DC_PRED 9 | 49 | #define LEFT_DC_PRED 9 |
| 50 | #define TOP_DC_PRED 10 | 50 | #define TOP_DC_PRED 10 |
| 51 | #define DC_128_PRED 11 | 51 | #define DC_128_PRED 11 |
| 52 | 52 | ||
| @@ -56,7 +56,7 @@ · 3 unmodified lines | |||
| 56 | #define VERT_LEFT_PRED_RV40_NODOWN 14 | 56 | #define VERT_LEFT_PRED_RV40_NODOWN 14 |
| 57 | 57 | ||
| 58 | // VP8 specific | 58 | // VP8 specific |
| 59 | #define TM_VP8_PRED 9 ///< "True Motion", used instead of plane | 59 | #define TM_VP8_PRED 9 ///< "True Motion", used instead of plane |
| 60 | #define VERT_VP8_PRED 10 ///< for VP8, #VERT_PRED is the average of | 60 | #define VERT_VP8_PRED 10 ///< for VP8, #VERT_PRED is the average of |
| 61 | ///< (left col+cur col x2+right col) / 4; | 61 | ///< (left col+cur col x2+right col) / 4; |
| 62 | ///< this is the "unaveraged" one | 62 | ///< this is the "unaveraged" one |
| @@ -65,44 +65,53 @@ · 2 unmodified lines | |||
| 65 | #define DC_127_PRED 12 | 65 | #define DC_127_PRED 12 |
| 66 | #define DC_129_PRED 13 | 66 | #define DC_129_PRED 13 |
| 67 | 67 | ||
| 68 | #define DC_PRED8x8 0 | 68 | #define DC_PRED8x8 0 |
| 69 | #define HOR_PRED8x8 1 | 69 | #define HOR_PRED8x8 1 |
| 70 | #define VERT_PRED8x8 2 | 70 | #define VERT_PRED8x8 2 |
| 71 | #define PLANE_PRED8x8 3 | 71 | #define PLANE_PRED8x8 3 |
| 72 | 72 | ||
| 73 | // DC edge | 73 | // DC edge |
| 74 | #define LEFT_DC_PRED8x8 4 | 74 | #define LEFT_DC_PRED8x8 4 |
| 75 | #define TOP_DC_PRED8x8 5 | 75 | #define TOP_DC_PRED8x8 5 |
| 76 | #define DC_128_PRED8x8 6 | 76 | #define DC_128_PRED8x8 6 |
| 77 | 77 | ||
| 78 | // H264/SVQ3 (8x8) specific | 78 | // H264/SVQ3 (8x8) specific |
| 79 | #define ALZHEIMER_DC_L0T_PRED8x8 7 | 79 | #define ALZHEIMER_DC_L0T_PRED8x8 7 |
| 80 | #define ALZHEIMER_DC_0LT_PRED8x8 8 | 80 | #define ALZHEIMER_DC_0LT_PRED8x8 8 |
| 81 | #define ALZHEIMER_DC_L00_PRED8x8 9 | 81 | #define ALZHEIMER_DC_L00_PRED8x8 9 |
| 82 | #define ALZHEIMER_DC_0L0_PRED8x8 10 | 82 | #define ALZHEIMER_DC_0L0_PRED8x8 10 |
| 83 | 83 | ||
| 84 | // VP8 specific | 84 | // VP8 specific |
| 85 | #define DC_127_PRED8x8 7 | 85 | #define DC_127_PRED8x8 7 |
| 86 | #define DC_129_PRED8x8 8 | 86 | #define DC_129_PRED8x8 8 |
| 87 | //@} | 87 | //@} |
| 88 | 88 | ||
| 89 | /** | 89 | /** |
| 90 | * Context for storing H.264 prediction functions | 90 | * Context for storing H.264 prediction functions |
| 91 | */ | 91 | */ |
| 92 | typedef struct H264PredContext{ | 92 | typedef struct H264PredContext { |
| 93 | void (*pred4x4 [9+3+3])(uint8_t *src, const uint8_t *topright, int stride);//FIXME move to dsp? | 93 | void(*pred4x4[9 + 3 + 3])(uint8_t *src, const uint8_t *topright, int stride); //FIXME move to dsp? |
| 94 | void (*pred8x8l [9+3])(uint8_t *src, int topleft, int topright, int stride); | 94 | void(*pred8x8l[9 + 3])(uint8_t *src, int topleft, int topright, int stride); |
| 95 | void (*pred8x8 [4+3+4])(uint8_t *src, int stride); | 95 | void(*pred8x8[4 + 3 + 4])(uint8_t *src, int stride); |
| 96 | void (*pred16x16[4+3+2])(uint8_t *src, int stride); | 96 | void(*pred16x16[4 + 3 + 2])(uint8_t *src, int stride); |
| 97 | 97 | ||
| 98 | void (*pred4x4_add [2])(uint8_t *pix/*align 4*/, const DCTELEM *block/*align 16*/, int stride); | 98 | void(*pred4x4_add[2])(uint8_t *pix /*align 4*/, |
| 99 | void (*pred8x8l_add [2])(uint8_t *pix/*align 8*/, const DCTELEM *block/*align 16*/, int stride); | 99 | const DCTELEM *block /*align 16*/, int stride); |
| 100 | void (*pred8x8_add [3])(uint8_t *pix/*align 8*/, const int *block_offset, const DCTELEM *block/*align 16*/, int stride); | 100 | void(*pred8x8l_add[2])(uint8_t *pix /*align 8*/, |
| 101 | void (*pred16x16_add[3])(uint8_t *pix/*align 16*/, const int *block_offset, const DCTELEM *block/*align 16*/, int stride); | 101 | const DCTELEM *block /*align 16*/, int stride); |
| 102 | }H264PredContext; | 102 | void(*pred8x8_add[3])(uint8_t *pix /*align 8*/, |
| 103 | const int *block_offset, | ||
| 104 | const DCTELEM *block /*align 16*/, int stride); | ||
| 105 | void(*pred16x16_add[3])(uint8_t *pix /*align 16*/, | ||
| 106 | const int *block_offset, | ||
| 107 | const DCTELEM *block /*align 16*/, int stride); | ||
| 108 | } H264PredContext; | ||
| 103 | 109 | ||
| 104 | void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); | 110 | void ff_h264_pred_init(H264PredContext *h, int codec_id, |
| 105 | void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); | 111 | const int bit_depth, const int chroma_format_idc); |
| 106 | void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); | 112 | void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, |
| 113 | const int bit_depth, const int chroma_format_idc); | ||
| 114 | void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, | ||
| 115 | const int bit_depth, const int chroma_format_idc); | ||
| 107 | 116 | ||
| 108 | #endif /* AVCODEC_H264PRED_H */ | 117 | #endif /* AVCODEC_H264PRED_H */ |
| @@ -21,39 +21,57 @@ · 20 unmodified lines | |||
| 21 | 21 | ||
| 22 | /** | 22 | /** |
| 23 | * @file | 23 | * @file |
| 24 | * ati vcr1 codec. | 24 | * ATI VCR1 codec |
| 25 | */ | 25 | */ |
| 26 | 26 | ||
| 27 | #include "avcodec.h" | 27 | #include "avcodec.h" |
| 28 | #include "dsputil.h" | 28 | #include "dsputil.h" |
| 29 | 29 | ||
| 30 | //#undef NDEBUG | 30 | typedef struct VCR1Context { |
| 31 | //#include <assert.h> | ||
| 32 | |||
| 33 | /* Disable the encoder. */ | ||
| 34 | #undef CONFIG_VCR1_ENCODER | ||
| 35 | #define CONFIG_VCR1_ENCODER 0 | ||
| 36 | |||
| 37 | typedef struct VCR1Context{ | ||
| 38 | AVCodecContext *avctx; | ||
| 39 | AVFrame picture; | 31 | AVFrame picture; |
| 40 | int delta[16]; | 32 | int delta[16]; |
| 41 | int offset[4]; | 33 | int offset[4]; |
| 42 | } VCR1Context; | 34 | } VCR1Context; |
| 43 | 35 | ||
| 44 | static int decode_frame(AVCodecContext *avctx, | 36 | static av_cold void common_init(AVCodecContext *avctx) |
| 45 | void *data, int *data_size, | 37 | { |
| 46 | AVPacket *avpkt) | 38 | VCR1Context *const a = avctx->priv_data; |
| 39 | |||
| 40 | avctx->coded_frame = &a->picture; | ||
| 41 | avcodec_get_frame_defaults(&a->picture); | ||
| 42 | } | ||
| 43 | |||
| 44 | static av_cold int decode_init(AVCodecContext *avctx) | ||
| 45 | { | ||
| 46 | common_init(avctx); | ||
| 47 | |||
| 48 | avctx->pix_fmt = PIX_FMT_YUV410P; | ||
| 49 | |||
| 50 | return 0; | ||
| 51 | } | ||
| 52 | |||
| 53 | static av_cold int decode_end(AVCodecContext *avctx) | ||
| 54 | { | ||
| 55 | VCR1Context *s = avctx->priv_data; | ||
| 56 | |||
| 57 | if (s->picture.data[0]) | ||
| 58 | avctx->release_buffer(avctx, &s->picture); | ||
| 59 | |||
| 60 | return 0; | ||
| 61 | } | ||
| 62 | |||
| 63 | static int decode_frame(AVCodecContext *avctx, void *data, | ||
| 64 | int *data_size, AVPacket *avpkt) | ||
| 47 | { | 65 | { |
| 48 | const uint8_t *buf = avpkt->data; | 66 | const uint8_t *buf = avpkt->data; |
| 49 | int buf_size = avpkt->size; | 67 | int buf_size = avpkt->size; |
| 50 | VCR1Context * const a = avctx->priv_data; | 68 | VCR1Context *const a = avctx->priv_data; |
| 51 | AVFrame *picture = data; | 69 | AVFrame *picture = data; |
| 52 | AVFrame * const p = &a->picture; | 70 | AVFrame *const p = &a->picture; |
| 53 | const uint8_t *bytestream= buf; | 71 | const uint8_t *bytestream = buf; |
| 54 | int i, x, y; | 72 | int i, x, y; |
| 55 | 73 | ||
| 56 | if(p->data[0]) | 74 | if (p->data[0]) |
| 57 | avctx->release_buffer(avctx, p); | 75 | avctx->release_buffer(avctx, p); |
| 58 | 76 | ||
| 59 | if(buf_size < 16 + avctx->height + avctx->width*avctx->height*5/8){ | 77 | if(buf_size < 16 + avctx->height + avctx->width*avctx->height*5/8){ |
| @@ -61,57 +79,57 @@ static int decode_frame(AVCodecContext *avctx, · 1 unmodified line | |||
| 61 | return AVERROR(EINVAL); | 79 | return AVERROR(EINVAL); |
| 62 | } | 80 | } |
| 63 | 81 | ||
| 64 | p->reference= 0; | 82 | p->reference = 0; |
| 65 | if(avctx->get_buffer(avctx, p) < 0){ | 83 | if (avctx->get_buffer(avctx, p) < 0) { |
| 66 | av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | 84 | av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
| 67 | return -1; | 85 | return -1; |
| 68 | } | 86 | } |
| 69 | p->pict_type= AV_PICTURE_TYPE_I; | 87 | p->pict_type = AV_PICTURE_TYPE_I; |
| 70 | p->key_frame= 1; | 88 | p->key_frame = 1; |
| 71 | 89 | ||
| 72 | for(i=0; i<16; i++){ | 90 | for (i = 0; i < 16; i++) { |
| 73 | a->delta[i]= *(bytestream++); | 91 | a->delta[i] = *bytestream++; |
| 74 | bytestream++; | 92 | bytestream++; |
| 75 | } | 93 | } |
| 76 | 94 | ||
| 77 | for(y=0; y<avctx->height; y++){ | 95 | for (y = 0; y < avctx->height; y++) { |
| 78 | int offset; | 96 | int offset; |
| 79 | uint8_t *luma= &a->picture.data[0][ y*a->picture.linesize[0] ]; | 97 | uint8_t *luma = &a->picture.data[0][y * a->picture.linesize[0]]; |
| 80 | 98 | ||
| 81 | if((y&3) == 0){ | 99 | if ((y & 3) == 0) { |
| 82 | uint8_t *cb= &a->picture.data[1][ (y>>2)*a->picture.linesize[1] ]; | 100 | uint8_t *cb = &a->picture.data[1][(y >> 2) * a->picture.linesize[1]]; |
| 83 | uint8_t *cr= &a->picture.data[2][ (y>>2)*a->picture.linesize[2] ]; | 101 | uint8_t *cr = &a->picture.data[2][(y >> 2) * a->picture.linesize[2]]; |
| 84 | 102 | ||
| 85 | for(i=0; i<4; i++) | 103 | for (i = 0; i < 4; i++) |
| 86 | a->offset[i]= *(bytestream++); | 104 | a->offset[i] = *bytestream++; |
| 87 | 105 | ||
| 88 | offset= a->offset[0] - a->delta[ bytestream[2]&0xF ]; | 106 | offset = a->offset[0] - a->delta[bytestream[2] & 0xF]; |
| 89 | for(x=0; x<avctx->width; x+=4){ | 107 | for (x = 0; x < avctx->width; x += 4) { |
| 90 | luma[0]=( offset += a->delta[ bytestream[2]&0xF ]); | 108 | luma[0] = offset += a->delta[bytestream[2] & 0xF]; |
| 91 | luma[1]=( offset += a->delta[ bytestream[2]>>4 ]); | 109 | luma[1] = offset += a->delta[bytestream[2] >> 4]; |
| 92 | luma[2]=( offset += a->delta[ bytestream[0]&0xF ]); | 110 | luma[2] = offset += a->delta[bytestream[0] & 0xF]; |
| 93 | luma[3]=( offset += a->delta[ bytestream[0]>>4 ]); | 111 | luma[3] = offset += a->delta[bytestream[0] >> 4]; |
| 94 | luma += 4; | 112 | luma += 4; |
| 95 | 113 | ||
| 96 | *(cb++) = bytestream[3]; | 114 | *cb++ = bytestream[3]; |
| 97 | *(cr++) = bytestream[1]; | 115 | *cr++ = bytestream[1]; |
| 98 | 116 | ||
| 99 | bytestream+= 4; | 117 | bytestream += 4; |
| 100 | } | 118 | } |
| 101 | }else{ | 119 | } else { |
| 102 | offset= a->offset[y&3] - a->delta[ bytestream[2]&0xF ]; | 120 | offset = a->offset[y & 3] - a->delta[bytestream[2] & 0xF]; |
| 103 | 121 | ||
| 104 | for(x=0; x<avctx->width; x+=8){ | 122 | for (x = 0; x < avctx->width; x += 8) { |
| 105 | luma[0]=( offset += a->delta[ bytestream[2]&0xF ]); | 123 | luma[0] = offset += a->delta[bytestream[2] & 0xF]; |
| 106 | luma[1]=( offset += a->delta[ bytestream[2]>>4 ]); | 124 | luma[1] = offset += a->delta[bytestream[2] >> 4]; |
| 107 | luma[2]=( offset += a->delta[ bytestream[3]&0xF ]); | 125 | luma[2] = offset += a->delta[bytestream[3] & 0xF]; |
| 108 | luma[3]=( offset += a->delta[ bytestream[3]>>4 ]); | 126 | luma[3] = offset += a->delta[bytestream[3] >> 4]; |
| 109 | luma[4]=( offset += a->delta[ bytestream[0]&0xF ]); | 127 | luma[4] = offset += a->delta[bytestream[0] & 0xF]; |
| 110 | luma[5]=( offset += a->delta[ bytestream[0]>>4 ]); | 128 | luma[5] = offset += a->delta[bytestream[0] >> 4]; |
| 111 | luma[6]=( offset += a->delta[ bytestream[1]&0xF ]); | 129 | luma[6] = offset += a->delta[bytestream[1] & 0xF]; |
| 112 | luma[7]=( offset += a->delta[ bytestream[1]>>4 ]); | 130 | luma[7] = offset += a->delta[bytestream[1] >> 4]; |
| 113 | luma += 8; | 131 | luma += 8; |
| 114 | bytestream+= 4; | 132 | bytestream += 4; |
| 115 | } | 133 | } |
| 116 | } | 134 | } |
| 117 | } | 135 | } |
| @@ -122,62 +140,6 @@ static int decode_frame(AVCodecContext *avctx, · 4 unmodified lines | |||
| 122 | return buf_size; | 140 | return buf_size; |
| 123 | } | 141 | } |
| 124 | 142 | ||
| 125 | #if CONFIG_VCR1_ENCODER | ||
| 126 | static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ | ||
| 127 | VCR1Context * const a = avctx->priv_data; | ||
| 128 | AVFrame *pict = data; | ||
| 129 | AVFrame * const p = &a->picture; | ||
| 130 | int size; | ||
| 131 | |||
| 132 | *p = *pict; | ||
| 133 | p->pict_type= AV_PICTURE_TYPE_I; | ||
| 134 | p->key_frame= 1; | ||
| 135 | |||
| 136 | avpriv_align_put_bits(&a->pb); | ||
| 137 | while(get_bit_count(&a->pb)&31) | ||
| 138 | put_bits(&a->pb, 8, 0); | ||
| 139 | |||
| 140 | size= get_bit_count(&a->pb)/32; | ||
| 141 | |||
| 142 | return size*4; | ||
| 143 | } | ||
| 144 | #endif | ||
| 145 | |||
| 146 | static av_cold void common_init(AVCodecContext *avctx){ | ||
| 147 | VCR1Context * const a = avctx->priv_data; | ||
| 148 | |||
| 149 | avctx->coded_frame = &a->picture; | ||
| 150 | avcodec_get_frame_defaults(&a->picture); | ||
| 151 | a->avctx= avctx; | ||
| 152 | } | ||
| 153 | |||
| 154 | static av_cold int decode_init(AVCodecContext *avctx){ | ||
| 155 | |||
| 156 | common_init(avctx); | ||
| 157 | |||
| 158 | avctx->pix_fmt= PIX_FMT_YUV410P; | ||
| 159 | |||
| 160 | return 0; | ||
| 161 | } | ||
| 162 | |||
| 163 | static av_cold int decode_end(AVCodecContext *avctx){ | ||
| 164 | VCR1Context *s = avctx->priv_data; | ||
| 165 | |||
| 166 | if (s->picture.data[0]) | ||
| 167 | avctx->release_buffer(avctx, &s->picture); | ||
| 168 | |||
| 169 | return 0; | ||
| 170 | } | ||
| 171 | |||
| 172 | #if CONFIG_VCR1_ENCODER | ||
| 173 | static av_cold int encode_init(AVCodecContext *avctx){ | ||
| 174 | |||
| 175 | common_init(avctx); | ||
| 176 | |||
| 177 | return 0; | ||
| 178 | } | ||
| 179 | #endif | ||
| 180 | |||
| 181 | AVCodec ff_vcr1_decoder = { | 143 | AVCodec ff_vcr1_decoder = { |
| 182 | .name = "vcr1", | 144 | .name = "vcr1", |
| 183 | .type = AVMEDIA_TYPE_VIDEO, | 145 | .type = AVMEDIA_TYPE_VIDEO, |
| @@ -190,14 +152,39 @@ AVCodec ff_vcr1_decoder = { · 6 unmodified lines | |||
| 190 | .long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"), | 152 | .long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"), |
| 191 | }; | 153 | }; |
| 192 | 154 | ||
| 155 | /* Disable the encoder. */ | ||
| 156 | #undef CONFIG_VCR1_ENCODER | ||
| 157 | #define CONFIG_VCR1_ENCODER 0 | ||
| 158 | |||
| 193 | #if CONFIG_VCR1_ENCODER | 159 | #if CONFIG_VCR1_ENCODER |
| 160 | static int encode_frame(AVCodecContext *avctx, unsigned char *buf, | ||
| 161 | int buf_size, void *data) | ||
| 162 | { | ||
| 163 | VCR1Context *const a = avctx->priv_data; | ||
| 164 | AVFrame *pict = data; | ||
| 165 | AVFrame *const p = &a->picture; | ||
| 166 | int size; | ||
| 167 | |||
| 168 | *p = *pict; | ||
| 169 | p->pict_type = AV_PICTURE_TYPE_I; | ||
| 170 | p->key_frame = 1; | ||
| 171 | |||
| 172 | avpriv_align_put_bits(&a->pb); | ||
| 173 | while (get_bit_count(&a->pb) & 31) | ||
| 174 | put_bits(&a->pb, 8, 0); | ||
| 175 | |||
| 176 | size = get_bit_count(&a->pb) / 32; | ||
| 177 | |||
| 178 | return size * 4; | ||
| 179 | } | ||
| 180 | |||
| 194 | AVCodec ff_vcr1_encoder = { | 181 | AVCodec ff_vcr1_encoder = { |
| 195 | .name = "vcr1", | 182 | .name = "vcr1", |
| 196 | .type = AVMEDIA_TYPE_VIDEO, | 183 | .type = AVMEDIA_TYPE_VIDEO, |
| 197 | .id = CODEC_ID_VCR1, | 184 | .id = CODEC_ID_VCR1, |
| 198 | .priv_data_size = sizeof(VCR1Context), | 185 | .priv_data_size = sizeof(VCR1Context), |
| 199 | .init = encode_init, | 186 | .init = common_init, |
| 200 | .encode = encode_frame, | 187 | .encode = encode_frame, |
| 201 | .long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"), | 188 | .long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"), |
| 202 | }; | 189 | }; |
| 203 | #endif | 190 | #endif /* CONFIG_VCR1_ENCODER */ |
| @@ -1792,6 +1792,22 @@ QPEL_2TAP(avg_, 16, 3dnow) · 1791 unmodified lines | |||
| 1792 | QPEL_2TAP(put_, 8, 3dnow) | 1792 | QPEL_2TAP(put_, 8, 3dnow) |
| 1793 | QPEL_2TAP(avg_, 8, 3dnow) | 1793 | QPEL_2TAP(avg_, 8, 3dnow) |
| 1794 | 1794 | ||
| 1795 | void ff_put_rv40_qpel8_mc33_mmx(uint8_t *dst, uint8_t *src, int stride) | ||
| 1796 | { | ||
| 1797 | put_pixels8_xy2_mmx(dst, src, stride, 8); | ||
| 1798 | } | ||
| 1799 | void ff_put_rv40_qpel16_mc33_mmx(uint8_t *dst, uint8_t *src, int stride) | ||
| 1800 | { | ||
| 1801 | put_pixels16_xy2_mmx(dst, src, stride, 16); | ||
| 1802 | } | ||
| 1803 | void ff_avg_rv40_qpel8_mc33_mmx(uint8_t *dst, uint8_t *src, int stride) | ||
| 1804 | { | ||
| 1805 | avg_pixels8_xy2_mmx(dst, src, stride, 8); | ||
| 1806 | } | ||
| 1807 | void ff_avg_rv40_qpel16_mc33_mmx(uint8_t *dst, uint8_t *src, int stride) | ||
| 1808 | { | ||
| 1809 | avg_pixels16_xy2_mmx(dst, src, stride, 16); | ||
| 1810 | } | ||
| 1795 | 1811 | ||
| 1796 | #if HAVE_YASM | 1812 | #if HAVE_YASM |
| 1797 | typedef void emu_edge_core_func(uint8_t *buf, const uint8_t *src, | 1813 | typedef void emu_edge_core_func(uint8_t *buf, const uint8_t *src, |
| @@ -199,6 +199,11 @@ void ff_avg_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); · 198 unmodified lines | |||
| 199 | void ff_put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd); | 199 | void ff_put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd); |
| 200 | void ff_avg_vc1_mspel_mc00_mmx2(uint8_t *dst, const uint8_t *src, int stride, int rnd); | 200 | void ff_avg_vc1_mspel_mc00_mmx2(uint8_t *dst, const uint8_t *src, int stride, int rnd); |
| 201 | 201 | ||
| 202 | void ff_put_rv40_qpel8_mc33_mmx(uint8_t *block, uint8_t *pixels, int line_size); | ||
| 203 | void ff_put_rv40_qpel16_mc33_mmx(uint8_t *block, uint8_t *pixels, int line_size); | ||
| 204 | void ff_avg_rv40_qpel8_mc33_mmx(uint8_t *block, uint8_t *pixels, int line_size); | ||
| 205 | void ff_avg_rv40_qpel16_mc33_mmx(uint8_t *block, uint8_t *pixels, int line_size); | ||
| 206 | |||
| 202 | void ff_mmx_idct(DCTELEM *block); | 207 | void ff_mmx_idct(DCTELEM *block); |
| 203 | void ff_mmxext_idct(DCTELEM *block); | 208 | void ff_mmxext_idct(DCTELEM *block); |
| 204 | 209 | ||
| @@ -1,5 +1,7 @@ | |||
| 1 | ;****************************************************************************** | 1 | ;****************************************************************************** |
| 2 | ;* MMX/SSE2-optimized functions for the RV40 decoder | 2 | ;* MMX/SSE2-optimized functions for the RV40 decoder |
| 3 | ;* Copyright (c) 2010 Ronald S. Bultje <rsbultje@gmail.com> | ||
| 4 | ;* Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@gmail.com> | ||
| 3 | ;* Copyright (C) 2012 Christophe Gisquet <christophe.gisquet@gmail.com> | 5 | ;* Copyright (C) 2012 Christophe Gisquet <christophe.gisquet@gmail.com> |
| 4 | ;* | 6 | ;* |
| 5 | ;* This file is part of Libav. | 7 | ;* This file is part of Libav. |
| @@ -25,11 +27,319 @@ · 19 unmodified lines | |||
| 25 | SECTION_RODATA | 27 | SECTION_RODATA |
| 26 | 28 | ||
| 27 | align 16 | 29 | align 16 |
| 28 | shift_round: times 8 dw 1 << (16 - 6) | 30 | pw_1024: times 8 dw 1 << (16 - 6) ; pw_1024 |
| 29 | cextern pw_16 | 31 | |
| 32 | sixtap_filter_hb_m: times 8 db 1, -5 | ||
| 33 | times 8 db 52, 20 | ||
| 34 | ; multiplied by 2 to have the same shift | ||
| 35 | times 8 db 2, -10 | ||
| 36 | times 8 db 40, 40 | ||
| 37 | ; back to normal | ||
| 38 | times 8 db 1, -5 | ||
| 39 | times 8 db 20, 52 | ||
| 40 | |||
| 41 | sixtap_filter_v_m: times 8 dw 1 | ||
| 42 | times 8 dw -5 | ||
| 43 | times 8 dw 52 | ||
| 44 | times 8 dw 20 | ||
| 45 | ; multiplied by 2 to have the same shift | ||
| 46 | times 8 dw 2 | ||
| 47 | times 8 dw -10 | ||
| 48 | times 8 dw 40 | ||
| 49 | times 8 dw 40 | ||
| 50 | ; back to normal | ||
| 51 | times 8 dw 1 | ||
| 52 | times 8 dw -5 | ||
| 53 | times 8 dw 20 | ||
| 54 | times 8 dw 52 | ||
| 55 | |||
| 56 | %ifdef PIC | ||
| 57 | %define sixtap_filter_hw picregq | ||
| 58 | %define sixtap_filter_hb picregq | ||
| 59 | %define sixtap_filter_v picregq | ||
| 60 | %define npicregs 1 | ||
| 61 | %else | ||
| 62 | %define sixtap_filter_hw sixtap_filter_hw_m | ||
| 63 | %define sixtap_filter_hb sixtap_filter_hb_m | ||
| 64 | %define sixtap_filter_v sixtap_filter_v_m | ||
| 65 | %define npicregs 0 | ||
| 66 | %endif | ||
| 67 | |||
| 68 | filter_h6_shuf1: db 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 | ||
| 69 | filter_h6_shuf2: db 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10 | ||
| 70 | filter_h6_shuf3: db 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11 | ||
| 71 | |||
| 72 | cextern pw_32 | ||
| 73 | cextern pw_16 | ||
| 74 | cextern pw_512 | ||
| 30 | 75 | ||
| 31 | SECTION .text | 76 | SECTION .text |
| 32 | 77 | ||
| 78 | ;----------------------------------------------------------------------------- | ||
| 79 | ; subpel MC functions: | ||
| 80 | ; | ||
| 81 | ; void [put|rv40]_rv40_qpel_[h|v]_<opt>(uint8_t *dst, int deststride, | ||
| 82 | ; uint8_t *src, int srcstride, | ||
| 83 | ; int len, int m); | ||
| 84 | ;---------------------------------------------------------------------- | ||
| 85 | %macro LOAD 2 | ||
| 86 | %if WIN64 | ||
| 87 | movsxd %1q, %1d | ||
| 88 | %endif | ||
| 89 | %ifdef PIC | ||
| 90 | add %1q, picregq | ||
| 91 | %else | ||
| 92 | add %1q, %2 | ||
| 93 | %endif | ||
| 94 | %endmacro | ||
| 95 | |||
| 96 | %macro STORE 3 | ||
| 97 | %ifidn %3, avg | ||
| 98 | movh %2, [dstq] | ||
| 99 | %endif | ||
| 100 | packuswb %1, %1 | ||
| 101 | %ifidn %3, avg | ||
| 102 | %if cpuflag(3dnow) | ||
| 103 | pavgusb %1, %2 | ||
| 104 | %else | ||
| 105 | pavgb %1, %2 | ||
| 106 | %endif | ||
| 107 | %endif | ||
| 108 | movh [dstq], %1 | ||
| 109 | %endmacro | ||
| 110 | |||
| 111 | %macro FILTER_V 1 | ||
| 112 | cglobal %1_rv40_qpel_v, 6,6+npicregs,12, dst, dststride, src, srcstride, height, my, picreg | ||
| 113 | %ifdef PIC | ||
| 114 | lea picregq, [sixtap_filter_v_m] | ||
| 115 | %endif | ||
| 116 | pxor m7, m7 | ||
| 117 | LOAD my, sixtap_filter_v | ||
| 118 | |||
| 119 | ; read 5 lines | ||
| 120 | sub srcq, srcstrideq | ||
| 121 | sub srcq, srcstrideq | ||
| 122 | movh m0, [srcq] | ||
| 123 | movh m1, [srcq+srcstrideq] | ||
| 124 | movh m2, [srcq+srcstrideq*2] | ||
| 125 | lea srcq, [srcq+srcstrideq*2] | ||
| 126 | add srcq, srcstrideq | ||
| 127 | movh m3, [srcq] | ||
| 128 | movh m4, [srcq+srcstrideq] | ||
| 129 | punpcklbw m0, m7 | ||
| 130 | punpcklbw m1, m7 | ||
| 131 | punpcklbw m2, m7 | ||
| 132 | punpcklbw m3, m7 | ||
| 133 | punpcklbw m4, m7 | ||
| 134 | |||
| 135 | %ifdef m8 | ||
| 136 | mova m8, [myq+ 0] | ||
| 137 | mova m9, [myq+16] | ||
| 138 | mova m10, [myq+32] | ||
| 139 | mova m11, [myq+48] | ||
| 140 | %define COEFF05 m8 | ||
| 141 | %define COEFF14 m9 | ||
| 142 | %define COEFF2 m10 | ||
| 143 | %define COEFF3 m11 | ||
| 144 | %else | ||
| 145 | %define COEFF05 [myq+ 0] | ||
| 146 | %define COEFF14 [myq+16] | ||
| 147 | %define COEFF2 [myq+32] | ||
| 148 | %define COEFF3 [myq+48] | ||
| 149 | %endif | ||
| 150 | .nextrow: | ||
| 151 | mova m6, m1 | ||
| 152 | movh m5, [srcq+2*srcstrideq] ; read new row | ||
| 153 | paddw m6, m4 | ||
| 154 | punpcklbw m5, m7 | ||
| 155 | pmullw m6, COEFF14 | ||
| 156 | paddw m0, m5 | ||
| 157 | pmullw m0, COEFF05 | ||
| 158 | paddw m6, m0 | ||
| 159 | mova m0, m1 | ||
| 160 | paddw m6, [pw_32] | ||
| 161 | mova m1, m2 | ||
| 162 | pmullw m2, COEFF2 | ||
| 163 | paddw m6, m2 | ||
| 164 | mova m2, m3 | ||
| 165 | pmullw m3, COEFF3 | ||
| 166 | paddw m6, m3 | ||
| 167 | |||
| 168 | ; round/clip/store | ||
| 169 | mova m3, m4 | ||
| 170 | psraw m6, 6 | ||
| 171 | mova m4, m5 | ||
| 172 | STORE m6, m5, %1 | ||
| 173 | |||
| 174 | ; go to next line | ||
| 175 | add dstq, dststrideq | ||
| 176 | add srcq, srcstrideq | ||
| 177 | dec heightd ; next row | ||
| 178 | jg .nextrow | ||
| 179 | REP_RET | ||
| 180 | %endmacro | ||
| 181 | |||
| 182 | %macro FILTER_H 1 | ||
| 183 | cglobal %1_rv40_qpel_h, 6, 6+npicregs, 12, dst, dststride, src, srcstride, height, mx, picreg | ||
| 184 | %ifdef PIC | ||
| 185 | lea picregq, [sixtap_filter_v_m] | ||
| 186 | %endif | ||
| 187 | pxor m7, m7 | ||
| 188 | LOAD mx, sixtap_filter_v | ||
| 189 | mova m6, [pw_32] | ||
| 190 | %ifdef m8 | ||
| 191 | mova m8, [mxq+ 0] | ||
| 192 | mova m9, [mxq+16] | ||
| 193 | mova m10, [mxq+32] | ||
| 194 | mova m11, [mxq+48] | ||
| 195 | %define COEFF05 m8 | ||
| 196 | %define COEFF14 m9 | ||
| 197 | %define COEFF2 m10 | ||
| 198 | %define COEFF3 m11 | ||
| 199 | %else | ||
| 200 | %define COEFF05 [mxq+ 0] | ||
| 201 | %define COEFF14 [mxq+16] | ||
| 202 | %define COEFF2 [mxq+32] | ||
| 203 | %define COEFF3 [mxq+48] | ||
| 204 | %endif | ||
| 205 | .nextrow: | ||
| 206 | movq m0, [srcq-2] | ||
| 207 | movq m5, [srcq+3] | ||
| 208 | movq m1, [srcq-1] | ||
| 209 | movq m4, [srcq+2] | ||
| 210 | punpcklbw m0, m7 | ||
| 211 | punpcklbw m5, m7 | ||
| 212 | punpcklbw m1, m7 | ||
| 213 | punpcklbw m4, m7 | ||
| 214 | movq m2, [srcq-0] | ||
| 215 | movq m3, [srcq+1] | ||
| 216 | paddw m0, m5 | ||
| 217 | paddw m1, m4 | ||
| 218 | punpcklbw m2, m7 | ||
| 219 | punpcklbw m3, m7 | ||
| 220 | pmullw m0, COEFF05 | ||
| 221 | pmullw m1, COEFF14 | ||
| 222 | pmullw m2, COEFF2 | ||
| 223 | pmullw m3, COEFF3 | ||
| 224 | paddw m0, m6 | ||
| 225 | paddw m1, m2 | ||
| 226 | paddw m0, m3 | ||
| 227 | paddw m0, m1 | ||
| 228 | psraw m0, 6 | ||
| 229 | STORE m0, m1, %1 | ||
| 230 | |||
| 231 | ; go to next line | ||
| 232 | add dstq, dststrideq | ||
| 233 | add srcq, srcstrideq | ||
| 234 | dec heightd ; next row | ||
| 235 | jg .nextrow | ||
| 236 | REP_RET | ||
| 237 | %endmacro | ||
| 238 | |||
| 239 | %if ARCH_X86_32 | ||
| 240 | INIT_MMX mmx | ||
| 241 | FILTER_V put | ||
| 242 | FILTER_H put | ||
| 243 | |||
| 244 | INIT_MMX mmx2 | ||
| 245 | FILTER_V avg | ||
| 246 | FILTER_H avg | ||
| 247 | |||
| 248 | INIT_MMX 3dnow | ||
| 249 | FILTER_V avg | ||
| 250 | FILTER_H avg | ||
| 251 | %endif | ||
| 252 | |||
| 253 | INIT_XMM sse2 | ||
| 254 | FILTER_H put | ||
| 255 | FILTER_H avg | ||
| 256 | FILTER_V put | ||
| 257 | FILTER_V avg | ||
| 258 | |||
| 259 | %macro FILTER_SSSE3 1 | ||
| 260 | cglobal %1_rv40_qpel_v, 6,6+npicregs,8, dst, dststride, src, srcstride, height, my, picreg | ||
| 261 | %ifdef PIC | ||
| 262 | lea picregq, [sixtap_filter_hb_m] | ||
| 263 | %endif | ||
| 264 | |||
| 265 | ; read 5 lines | ||
| 266 | sub srcq, srcstrideq | ||
| 267 | LOAD my, sixtap_filter_hb | ||
| 268 | sub srcq, srcstrideq | ||
| 269 | movh m0, [srcq] | ||
| 270 | movh m1, [srcq+srcstrideq] | ||
| 271 | movh m2, [srcq+srcstrideq*2] | ||
| 272 | lea srcq, [srcq+srcstrideq*2] | ||
| 273 | add srcq, srcstrideq | ||
| 274 | mova m5, [myq] | ||
| 275 | movh m3, [srcq] | ||
| 276 | movh m4, [srcq+srcstrideq] | ||
| 277 | lea srcq, [srcq+2*srcstrideq] | ||
| 278 | |||
| 279 | .nextrow: | ||
| 280 | mova m6, m2 | ||
| 281 | punpcklbw m0, m1 | ||
| 282 | punpcklbw m6, m3 | ||
| 283 | pmaddubsw m0, m5 | ||
| 284 | pmaddubsw m6, [myq+16] | ||
| 285 | movh m7, [srcq] ; read new row | ||
| 286 | paddw m6, m0 | ||
| 287 | mova m0, m1 | ||
| 288 | mova m1, m2 | ||
| 289 | mova m2, m3 | ||
| 290 | mova m3, m4 | ||
| 291 | mova m4, m7 | ||
| 292 | punpcklbw m7, m3 | ||
| 293 | pmaddubsw m7, m5 | ||
| 294 | paddw m6, m7 | ||
| 295 | pmulhrsw m6, [pw_512] | ||
| 296 | STORE m6, m7, %1 | ||
| 297 | |||
| 298 | ; go to next line | ||
| 299 | add dstq, dststrideq | ||
| 300 | add srcq, srcstrideq | ||
| 301 | dec heightd ; next row | ||
| 302 | jg .nextrow | ||
| 303 | REP_RET | ||
| 304 | |||
| 305 | cglobal %1_rv40_qpel_h, 6,6+npicregs,8, dst, dststride, src, srcstride, height, mx, picreg | ||
| 306 | %ifdef PIC | ||
| 307 | lea picregq, [sixtap_filter_hb_m] | ||
| 308 | %endif | ||
| 309 | mova m3, [filter_h6_shuf2] | ||
| 310 | mova m4, [filter_h6_shuf3] | ||
| 311 | LOAD mx, sixtap_filter_hb | ||
| 312 | mova m5, [mxq] ; set up 6tap filter in bytes | ||
| 313 | mova m6, [mxq+16] | ||
| 314 | mova m7, [filter_h6_shuf1] | ||
| 315 | |||
| 316 | .nextrow: | ||
| 317 | movu m0, [srcq-2] | ||
| 318 | mova m1, m0 | ||
| 319 | mova m2, m0 | ||
| 320 | pshufb m0, m7 | ||
| 321 | pshufb m1, m3 | ||
| 322 | pshufb m2, m4 | ||
| 323 | pmaddubsw m0, m5 | ||
| 324 | pmaddubsw m1, m6 | ||
| 325 | pmaddubsw m2, m5 | ||
| 326 | paddw m0, m1 | ||
| 327 | paddw m0, m2 | ||
| 328 | pmulhrsw m0, [pw_512] | ||
| 329 | STORE m0, m1, %1 | ||
| 330 | |||
| 331 | ; go to next line | ||
| 332 | add dstq, dststrideq | ||
| 333 | add srcq, srcstrideq | ||
| 334 | dec heightd ; next row | ||
| 335 | jg .nextrow | ||
| 336 | REP_RET | ||
| 337 | %endmacro | ||
| 338 | |||
| 339 | INIT_XMM ssse3 | ||
| 340 | FILTER_SSSE3 put | ||
| 341 | FILTER_SSSE3 avg | ||
| 342 | |||
| 33 | ; %1=5bits weights?, %2=dst %3=src1 %4=src3 %5=stride if sse2 | 343 | ; %1=5bits weights?, %2=dst %3=src1 %4=src3 %5=stride if sse2 |
| 34 | %macro RV40_WCORE 4-5 | 344 | %macro RV40_WCORE 4-5 |
| 35 | movh m4, [%3 + r6 + 0] | 345 | movh m4, [%3 + r6 + 0] |
| @@ -143,7 +453,7 @@ SECTION .text · 107 unmodified lines | |||
| 143 | %macro RV40_WEIGHT 3 | 453 | %macro RV40_WEIGHT 3 |
| 144 | cglobal rv40_weight_func_%1_%2, 6, 7, 8 | 454 | cglobal rv40_weight_func_%1_%2, 6, 7, 8 |
| 145 | %if cpuflag(ssse3) | 455 | %if cpuflag(ssse3) |
| 146 | mova m1, [shift_round] | 456 | mova m1, [pw_1024] |
| 147 | %else | 457 | %else |
| 148 | mova m1, [pw_16] | 458 | mova m1, [pw_16] |
| 149 | %endif | 459 | %endif |
| @@ -22,8 +22,11 @@ · 21 unmodified lines | |||
| 22 | /** | 22 | /** |
| 23 | * @file | 23 | * @file |
| 24 | * RV40 decoder motion compensation functions x86-optimised | 24 | * RV40 decoder motion compensation functions x86-optimised |
| 25 | * 2,0 and 0,2 have h264 equivalents. | ||
| 26 | * 3,3 is bugged in the rv40 format and maps to _xy2 version | ||
| 25 | */ | 27 | */ |
| 26 | 28 | ||
| 29 | #include "libavcodec/x86/dsputil_mmx.h" | ||
| 27 | #include "libavcodec/rv34dsp.h" | 30 | #include "libavcodec/rv34dsp.h" |
| 28 | 31 | ||
| 29 | void ff_put_rv40_chroma_mc8_mmx (uint8_t *dst, uint8_t *src, | 32 | void ff_put_rv40_chroma_mc8_mmx (uint8_t *dst, uint8_t *src, |
| @@ -53,6 +56,132 @@ DECLARE_WEIGHT(mmx) · 23 unmodified lines | |||
| 53 | DECLARE_WEIGHT(sse2) | 56 | DECLARE_WEIGHT(sse2) |
| 54 | DECLARE_WEIGHT(ssse3) | 57 | DECLARE_WEIGHT(ssse3) |
| 55 | 58 | ||
| 59 | /** @{ */ | ||
| 60 | /** | ||
| 61 | * Define one qpel function. | ||
| 62 | * LOOPSIZE must be already set to the number of pixels processed per | ||
| 63 | * iteration in the inner loop of the called functions. | ||
| 64 | * COFF(x) must be already defined so as to provide the offset into any | ||
| 65 | * array of coeffs used by the called function for the qpel position x. | ||
| 66 | */ | ||
| 67 | #define QPEL_FUNC_DECL(OP, SIZE, PH, PV, OPT) \ | ||
| 68 | static void OP ## rv40_qpel ##SIZE ##_mc ##PH ##PV ##OPT(uint8_t *dst, \ | ||
| 69 | uint8_t *src, \ | ||
| 70 | int stride) \ | ||
| 71 | { \ | ||
| 72 | int i; \ | ||
| 73 | if (PH && PV) { \ | ||
| 74 | DECLARE_ALIGNED(16, uint8_t, tmp)[SIZE * (SIZE + 5)]; \ | ||
| 75 | uint8_t *tmpptr = tmp + SIZE * 2; \ | ||
| 76 | src -= stride * 2; \ | ||
| 77 | \ | ||
| 78 | for (i = 0; i < SIZE; i += LOOPSIZE) \ | ||
| 79 | ff_put_rv40_qpel_h ##OPT(tmp + i, SIZE, src + i, stride, \ | ||
| 80 | SIZE + 5, HCOFF(PH)); \ | ||
| 81 | for (i = 0; i < SIZE; i += LOOPSIZE) \ | ||
| 82 | ff_ ##OP ##rv40_qpel_v ##OPT(dst + i, stride, tmpptr + i, \ | ||
| 83 | SIZE, SIZE, VCOFF(PV)); \ | ||
| 84 | } else if (PV) { \ | ||
| 85 | for (i = 0; i < SIZE; i += LOOPSIZE) \ | ||
| 86 | ff_ ##OP ##rv40_qpel_v ## OPT(dst + i, stride, src + i, \ | ||
| 87 | stride, SIZE, VCOFF(PV)); \ | ||
| 88 | } else { \ | ||
| 89 | for (i = 0; i < SIZE; i += LOOPSIZE) \ | ||
| 90 | ff_ ##OP ##rv40_qpel_h ## OPT(dst + i, stride, src + i, \ | ||
| 91 | stride, SIZE, HCOFF(PH)); \ | ||
| 92 | } \ | ||
| 93 | }; | ||
| 94 | |||
| 95 | /** Declare functions for sizes 8 and 16 and given operations | ||
| 96 | * and qpel position. */ | ||
| 97 | #define QPEL_FUNCS_DECL(OP, PH, PV, OPT) \ | ||
| 98 | QPEL_FUNC_DECL(OP, 8, PH, PV, OPT) \ | ||
| 99 | QPEL_FUNC_DECL(OP, 16, PH, PV, OPT) | ||
| 100 | |||
| 101 | /** Declare all functions for all sizes and qpel positions */ | ||
| 102 | #define QPEL_MC_DECL(OP, OPT) \ | ||
| 103 | void ff_ ##OP ##rv40_qpel_h ##OPT(uint8_t *dst, ptrdiff_t dstStride, \ | ||
| 104 | const uint8_t *src, \ | ||
| 105 | ptrdiff_t srcStride, \ | ||
| 106 | int len, int m); \ | ||
| 107 | void ff_ ##OP ##rv40_qpel_v ##OPT(uint8_t *dst, ptrdiff_t dstStride, \ | ||
| 108 | const uint8_t *src, \ | ||
| 109 | ptrdiff_t srcStride, \ | ||
| 110 | int len, int m); \ | ||
| 111 | QPEL_FUNCS_DECL(OP, 0, 1, OPT) \ | ||
| 112 | QPEL_FUNCS_DECL(OP, 0, 3, OPT) \ | ||
| 113 | QPEL_FUNCS_DECL(OP, 1, 0, OPT) \ | ||
| 114 | QPEL_FUNCS_DECL(OP, 1, 1, OPT) \ | ||
| 115 | QPEL_FUNCS_DECL(OP, 1, 2, OPT) \ | ||
| 116 | QPEL_FUNCS_DECL(OP, 1, 3, OPT) \ | ||
| 117 | QPEL_FUNCS_DECL(OP, 2, 1, OPT) \ | ||
| 118 | QPEL_FUNCS_DECL(OP, 2, 2, OPT) \ | ||
| 119 | QPEL_FUNCS_DECL(OP, 2, 3, OPT) \ | ||
| 120 | QPEL_FUNCS_DECL(OP, 3, 0, OPT) \ | ||
| 121 | QPEL_FUNCS_DECL(OP, 3, 1, OPT) \ | ||
| 122 | QPEL_FUNCS_DECL(OP, 3, 2, OPT) | ||
| 123 | /** @} */ | ||
| 124 | |||
| 125 | #define LOOPSIZE 8 | ||
| 126 | #define HCOFF(x) (32 * (x - 1)) | ||
| 127 | #define VCOFF(x) (32 * (x - 1)) | ||
| 128 | QPEL_MC_DECL(put_, _ssse3) | ||
| 129 | QPEL_MC_DECL(avg_, _ssse3) | ||
| 130 | |||
| 131 | #undef LOOPSIZE | ||
| 132 | #undef HCOFF | ||
| 133 | #undef VCOFF | ||
| 134 | #define LOOPSIZE 8 | ||
| 135 | #define HCOFF(x) (64 * (x - 1)) | ||
| 136 | #define VCOFF(x) (64 * (x - 1)) | ||
| 137 | QPEL_MC_DECL(put_, _sse2) | ||
| 138 | QPEL_MC_DECL(avg_, _sse2) | ||
| 139 | |||
| 140 | #if ARCH_X86_32 | ||
| 141 | #undef LOOPSIZE | ||
| 142 | #undef HCOFF | ||
| 143 | #undef VCOFF | ||
| 144 | #define LOOPSIZE 4 | ||
| 145 | #define HCOFF(x) (64 * (x - 1)) | ||
| 146 | #define VCOFF(x) (64 * (x - 1)) | ||
| 147 | |||
| 148 | QPEL_MC_DECL(put_, _mmx) | ||
| 149 | |||
| 150 | #define ff_put_rv40_qpel_h_mmx2 ff_put_rv40_qpel_h_mmx | ||
| 151 | #define ff_put_rv40_qpel_v_mmx2 ff_put_rv40_qpel_v_mmx | ||
| 152 | QPEL_MC_DECL(avg_, _mmx2) | ||
| 153 | |||
| 154 | #define ff_put_rv40_qpel_h_3dnow ff_put_rv40_qpel_h_mmx | ||
| 155 | #define ff_put_rv40_qpel_v_3dnow ff_put_rv40_qpel_v_mmx | ||
| 156 | QPEL_MC_DECL(avg_, _3dnow) | ||
| 157 | #endif | ||
| 158 | |||
| 159 | /** @{ */ | ||
| 160 | /** Set one function */ | ||
| 161 | #define QPEL_FUNC_SET(OP, SIZE, PH, PV, OPT) \ | ||
| 162 | c-> OP ## pixels_tab[2 - SIZE / 8][4 * PV + PH] = OP ## rv40_qpel ##SIZE ## _mc ##PH ##PV ##OPT; | ||
| 163 | |||
| 164 | /** Set functions put and avg for sizes 8 and 16 and a given qpel position */ | ||
| 165 | #define QPEL_FUNCS_SET(OP, PH, PV, OPT) \ | ||
| 166 | QPEL_FUNC_SET(OP, 8, PH, PV, OPT) \ | ||
| 167 | QPEL_FUNC_SET(OP, 16, PH, PV, OPT) | ||
| 168 | |||
| 169 | /** Set all functions for all sizes and qpel positions */ | ||
| 170 | #define QPEL_MC_SET(OP, OPT) \ | ||
| 171 | QPEL_FUNCS_SET (OP, 0, 1, OPT) \ | ||
| 172 | QPEL_FUNCS_SET (OP, 0, 3, OPT) \ | ||
| 173 | QPEL_FUNCS_SET (OP, 1, 0, OPT) \ | ||
| 174 | QPEL_FUNCS_SET (OP, 1, 1, OPT) \ | ||
| 175 | QPEL_FUNCS_SET (OP, 1, 2, OPT) \ | ||
| 176 | QPEL_FUNCS_SET (OP, 1, 3, OPT) \ | ||
| 177 | QPEL_FUNCS_SET (OP, 2, 1, OPT) \ | ||
| 178 | QPEL_FUNCS_SET (OP, 2, 2, OPT) \ | ||
| 179 | QPEL_FUNCS_SET (OP, 2, 3, OPT) \ | ||
| 180 | QPEL_FUNCS_SET (OP, 3, 0, OPT) \ | ||
| 181 | QPEL_FUNCS_SET (OP, 3, 1, OPT) \ | ||
| 182 | QPEL_FUNCS_SET (OP, 3, 2, OPT) | ||
| 183 | /** @} */ | ||
| 184 | |||
| 56 | void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp) | 185 | void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp) |
| 57 | { | 186 | { |
| 58 | #if HAVE_YASM | 187 | #if HAVE_YASM |
| @@ -65,25 +194,42 @@ void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp) · 6 unmodified lines | |||
| 65 | c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_mmx; | 194 | c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_mmx; |
| 66 | c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_mmx; | 195 | c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_mmx; |
| 67 | c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_mmx; | 196 | c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_mmx; |
| 197 | c->put_pixels_tab[0][15] = ff_put_rv40_qpel16_mc33_mmx; | ||
| 198 | c->put_pixels_tab[1][15] = ff_put_rv40_qpel8_mc33_mmx; | ||
| 199 | c->avg_pixels_tab[0][15] = ff_avg_rv40_qpel16_mc33_mmx; | ||
| 200 | c->avg_pixels_tab[1][15] = ff_avg_rv40_qpel8_mc33_mmx; | ||
| 201 | #if ARCH_X86_32 | ||
| 202 | QPEL_MC_SET(put_, _mmx) | ||
| 203 | #endif | ||
| 68 | } | 204 | } |
| 69 | if (mm_flags & AV_CPU_FLAG_MMX2) { | 205 | if (mm_flags & AV_CPU_FLAG_MMX2) { |
| 70 | c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_mmx2; | 206 | c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_mmx2; |
| 71 | c->avg_chroma_pixels_tab[1] = ff_avg_rv40_chroma_mc4_mmx2; | 207 | c->avg_chroma_pixels_tab[1] = ff_avg_rv40_chroma_mc4_mmx2; |
| 208 | #if ARCH_X86_32 | ||
| 209 | QPEL_MC_SET(avg_, _mmx2) | ||
| 210 | #endif | ||
| 72 | } else if (mm_flags & AV_CPU_FLAG_3DNOW) { | 211 | } else if (mm_flags & AV_CPU_FLAG_3DNOW) { |
| 73 | c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_3dnow; | 212 | c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_3dnow; |
| 74 | c->avg_chroma_pixels_tab[1] = ff_avg_rv40_chroma_mc4_3dnow; | 213 | c->avg_chroma_pixels_tab[1] = ff_avg_rv40_chroma_mc4_3dnow; |
| 214 | #if ARCH_X86_32 | ||
| 215 | QPEL_MC_SET(avg_, _3dnow) | ||
| 216 | #endif | ||
| 75 | } | 217 | } |
| 76 | if (mm_flags & AV_CPU_FLAG_SSE2) { | 218 | if (mm_flags & AV_CPU_FLAG_SSE2) { |
| 77 | c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_sse2; | 219 | c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_sse2; |
| 78 | c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_sse2; | 220 | c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_sse2; |
| 79 | c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_sse2; | 221 | c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_sse2; |
| 80 | c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_sse2; | 222 | c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_sse2; |
| 223 | QPEL_MC_SET(put_, _sse2) | ||
| 224 | QPEL_MC_SET(avg_, _sse2) | ||
| 81 | } | 225 | } |
| 82 | if (mm_flags & AV_CPU_FLAG_SSSE3) { | 226 | if (mm_flags & AV_CPU_FLAG_SSSE3) { |
| 83 | c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_ssse3; | 227 | c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_ssse3; |
| 84 | c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_ssse3; | 228 | c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_ssse3; |
| 85 | c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_ssse3; | 229 | c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_ssse3; |
| 86 | c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_ssse3; | 230 | c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_ssse3; |
| 231 | QPEL_MC_SET(put_, _ssse3) | ||
| 232 | QPEL_MC_SET(avg_, _ssse3) | ||
| 87 | } | 233 | } |
| 88 | #endif | 234 | #endif |
| 89 | } | 235 | } |
| @@ -21,6 +21,7 @@ HEADERS = asrc_abuffer.h \ · 20 unmodified lines | |||
| 21 | vsrc_buffer.h \ | 21 | vsrc_buffer.h \ |
| 22 | 22 | ||
| 23 | OBJS = allfilters.o \ | 23 | OBJS = allfilters.o \ |
| 24 | audio.o \ | ||
| 24 | avfilter.o \ | 25 | avfilter.o \ |
| 25 | avfiltergraph.o \ | 26 | avfiltergraph.o \ |
| 26 | buffersink.o \ | 27 | buffersink.o \ |
| @@ -144,7 +144,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 143 unmodified lines | |||
| 144 | AConvertContext *aconvert = inlink->dst->priv; | 144 | AConvertContext *aconvert = inlink->dst->priv; |
| 145 | const int n = insamplesref->audio->nb_samples; | 145 | const int n = insamplesref->audio->nb_samples; |
| 146 | AVFilterLink *const outlink = inlink->dst->outputs[0]; | 146 | AVFilterLink *const outlink = inlink->dst->outputs[0]; |
| 147 | AVFilterBufferRef *outsamplesref = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, n); | 147 | AVFilterBufferRef *outsamplesref = ff_get_audio_buffer(outlink, AV_PERM_WRITE, n); |
| 148 | 148 | ||
| 149 | swr_convert(aconvert->swr, outsamplesref->data, n, | 149 | swr_convert(aconvert->swr, outsamplesref->data, n, |
| 150 | (void *)insamplesref->data, n); | 150 | (void *)insamplesref->data, n); |
| @@ -153,7 +153,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 2 unmodified lines | |||
| 153 | outsamplesref->audio->channel_layout = outlink->channel_layout; | 153 | outsamplesref->audio->channel_layout = outlink->channel_layout; |
| 154 | outsamplesref->audio->planar = outlink->planar; | 154 | outsamplesref->audio->planar = outlink->planar; |
| 155 | 155 | ||
| 156 | avfilter_filter_samples(outlink, outsamplesref); | 156 | ff_filter_samples(outlink, outsamplesref); |
| 157 | avfilter_unref_buffer(insamplesref); | 157 | avfilter_unref_buffer(insamplesref); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| @@ -89,7 +89,7 @@ static int query_formats(AVFilterContext *ctx) · 88 unmodified lines | |||
| 89 | 89 | ||
| 90 | static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref) | 90 | static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref) |
| 91 | { | 91 | { |
| 92 | avfilter_filter_samples(inlink->dst->outputs[0], insamplesref); | 92 | ff_filter_samples(inlink->dst->outputs[0], insamplesref); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | AVFilter avfilter_af_aformat = { | 95 | AVFilter avfilter_af_aformat = { |
| @@ -208,7 +208,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 207 unmodified lines | |||
| 208 | 208 | ||
| 209 | nb_samples = FFMIN(am->queue[0].nb_samples, | 209 | nb_samples = FFMIN(am->queue[0].nb_samples, |
| 210 | am->queue[1].nb_samples); | 210 | am->queue[1].nb_samples); |
| 211 | outbuf = avfilter_get_audio_buffer(ctx->outputs[0], AV_PERM_WRITE, | 211 | outbuf = ff_get_audio_buffer(ctx->outputs[0], AV_PERM_WRITE, |
| 212 | nb_samples); | 212 | nb_samples); |
| 213 | outs = outbuf->data[0]; | 213 | outs = outbuf->data[0]; |
| 214 | for (i = 0; i < 2; i++) { | 214 | for (i = 0; i < 2; i++) { |
| @@ -264,7 +264,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 49 unmodified lines | |||
| 264 | am->queue[i].nb_buf * sizeof(**inbuf)); | 264 | am->queue[i].nb_buf * sizeof(**inbuf)); |
| 265 | } | 265 | } |
| 266 | } | 266 | } |
| 267 | avfilter_filter_samples(ctx->outputs[0], outbuf); | 267 | ff_filter_samples(ctx->outputs[0], outbuf); |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | AVFilter avfilter_af_amerge = { | 270 | AVFilter avfilter_af_amerge = { |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | |||
| 21 | * null audio filter | 21 | * null audio filter |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #include "audio.h" | ||
| 24 | #include "avfilter.h" | 25 | #include "avfilter.h" |
| 25 | 26 | ||
| 26 | AVFilter avfilter_af_anull = { | 27 | AVFilter avfilter_af_anull = { |
| @@ -31,8 +32,8 @@ AVFilter avfilter_af_anull = { · 4 unmodified lines | |||
| 31 | 32 | ||
| 32 | .inputs = (const AVFilterPad[]) {{ .name = "default", | 33 | .inputs = (const AVFilterPad[]) {{ .name = "default", |
| 33 | .type = AVMEDIA_TYPE_AUDIO, | 34 | .type = AVMEDIA_TYPE_AUDIO, |
| 34 | .get_audio_buffer = avfilter_null_get_audio_buffer, | 35 | .get_audio_buffer = ff_null_get_audio_buffer, |
| 35 | .filter_samples = avfilter_null_filter_samples }, | 36 | .filter_samples = ff_null_filter_samples }, |
| 36 | { .name = NULL}}, | 37 | { .name = NULL}}, |
| 37 | 38 | ||
| 38 | .outputs = (const AVFilterPad[]) {{ .name = "default", | 39 | .outputs = (const AVFilterPad[]) {{ .name = "default", |
| @@ -92,7 +92,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 91 unmodified lines | |||
| 92 | const int n_in = insamplesref->audio->nb_samples; | 92 | const int n_in = insamplesref->audio->nb_samples; |
| 93 | int n_out = n_in * aresample->ratio; | 93 | int n_out = n_in * aresample->ratio; |
| 94 | AVFilterLink *const outlink = inlink->dst->outputs[0]; | 94 | AVFilterLink *const outlink = inlink->dst->outputs[0]; |
| 95 | AVFilterBufferRef *outsamplesref = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, n_out); | 95 | AVFilterBufferRef *outsamplesref = ff_get_audio_buffer(outlink, AV_PERM_WRITE, n_out); |
| 96 | 96 | ||
| 97 | n_out = swr_convert(aresample->swr, outsamplesref->data, n_out, | 97 | n_out = swr_convert(aresample->swr, outsamplesref->data, n_out, |
| 98 | (void *)insamplesref->data, n_in); | 98 | (void *)insamplesref->data, n_in); |
| @@ -103,7 +103,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 4 unmodified lines | |||
| 103 | outsamplesref->pts = insamplesref->pts == AV_NOPTS_VALUE ? AV_NOPTS_VALUE : | 103 | outsamplesref->pts = insamplesref->pts == AV_NOPTS_VALUE ? AV_NOPTS_VALUE : |
| 104 | av_rescale(outlink->sample_rate, insamplesref->pts, inlink ->sample_rate); | 104 | av_rescale(outlink->sample_rate, insamplesref->pts, inlink ->sample_rate); |
| 105 | 105 | ||
| 106 | avfilter_filter_samples(outlink, outsamplesref); | 106 | ff_filter_samples(outlink, outsamplesref); |
| 107 | avfilter_unref_buffer(insamplesref); | 107 | avfilter_unref_buffer(insamplesref); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| @@ -83,7 +83,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) · 82 unmodified lines | |||
| 83 | av_log(ctx, AV_LOG_INFO, "]\n"); | 83 | av_log(ctx, AV_LOG_INFO, "]\n"); |
| 84 | 84 | ||
| 85 | showinfo->frame++; | 85 | showinfo->frame++; |
| 86 | avfilter_filter_samples(inlink->dst->outputs[0], samplesref); | 86 | ff_filter_samples(inlink->dst->outputs[0], samplesref); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | AVFilter avfilter_af_ashowinfo = { | 89 | AVFilter avfilter_af_ashowinfo = { |
| @@ -95,7 +95,7 @@ AVFilter avfilter_af_ashowinfo = { · 5 unmodified lines | |||
| 95 | 95 | ||
| 96 | .inputs = (const AVFilterPad[]) {{ .name = "default", | 96 | .inputs = (const AVFilterPad[]) {{ .name = "default", |
| 97 | .type = AVMEDIA_TYPE_AUDIO, | 97 | .type = AVMEDIA_TYPE_AUDIO, |
| 98 | .get_audio_buffer = avfilter_null_get_audio_buffer, | 98 | .get_audio_buffer = ff_null_get_audio_buffer, |
| 99 | .filter_samples = filter_samples, | 99 | .filter_samples = filter_samples, |
| 100 | .min_perms = AV_PERM_READ, }, | 100 | .min_perms = AV_PERM_READ, }, |
| 101 | { .name = NULL}}, | 101 | { .name = NULL}}, |
| @@ -27,9 +27,9 @@ · 26 unmodified lines | |||
| 27 | 27 | ||
| 28 | static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) | 28 | static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) |
| 29 | { | 29 | { |
| 30 | avfilter_filter_samples(inlink->dst->outputs[0], | 30 | ff_filter_samples(inlink->dst->outputs[0], |
| 31 | avfilter_ref_buffer(insamples, ~AV_PERM_WRITE)); | 31 | avfilter_ref_buffer(insamples, ~AV_PERM_WRITE)); |
| 32 | avfilter_filter_samples(inlink->dst->outputs[1], | 32 | ff_filter_samples(inlink->dst->outputs[1], |
| 33 | avfilter_ref_buffer(insamples, ~AV_PERM_WRITE)); | 33 | avfilter_ref_buffer(insamples, ~AV_PERM_WRITE)); |
| 34 | avfilter_unref_buffer(insamples); | 34 | avfilter_unref_buffer(insamples); |
| 35 | } | 35 | } |
| @@ -41,7 +41,7 @@ AVFilter avfilter_af_asplit = { · 5 unmodified lines | |||
| 41 | .inputs = (const AVFilterPad[]) { | 41 | .inputs = (const AVFilterPad[]) { |
| 42 | { .name = "default", | 42 | { .name = "default", |
| 43 | .type = AVMEDIA_TYPE_AUDIO, | 43 | .type = AVMEDIA_TYPE_AUDIO, |
| 44 | .get_audio_buffer = avfilter_null_get_audio_buffer, | 44 | .get_audio_buffer = ff_null_get_audio_buffer, |
| 45 | .filter_samples = filter_samples, }, | 45 | .filter_samples = filter_samples, }, |
| 46 | { .name = NULL} | 46 | { .name = NULL} |
| 47 | }, | 47 | }, |
| @@ -119,7 +119,7 @@ static void send_out(AVFilterContext *ctx, int out_id) · 118 unmodified lines | |||
| 119 | av_q2d(ctx->outputs[out_id]->time_base) * buf->pts; | 119 | av_q2d(ctx->outputs[out_id]->time_base) * buf->pts; |
| 120 | as->var_values[VAR_T1 + out_id] += buf->audio->nb_samples / | 120 | as->var_values[VAR_T1 + out_id] += buf->audio->nb_samples / |
| 121 | (double)ctx->inputs[out_id]->sample_rate; | 121 | (double)ctx->inputs[out_id]->sample_rate; |
| 122 | avfilter_filter_samples(ctx->outputs[out_id], buf); | 122 | ff_filter_samples(ctx->outputs[out_id], buf); |
| 123 | queue->nb--; | 123 | queue->nb--; |
| 124 | queue->tail = (queue->tail + 1) % QUEUE_SIZE; | 124 | queue->tail = (queue->tail + 1) % QUEUE_SIZE; |
| 125 | if (as->req[out_id]) | 125 | if (as->req[out_id]) |
| @@ -122,7 +122,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 121 unmodified lines | |||
| 122 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 122 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 123 | int16_t *taps, *endin, *in, *out; | 123 | int16_t *taps, *endin, *in, *out; |
| 124 | AVFilterBufferRef *outsamples = | 124 | AVFilterBufferRef *outsamples = |
| 125 | avfilter_get_audio_buffer(inlink, AV_PERM_WRITE, | 125 | ff_get_audio_buffer(inlink, AV_PERM_WRITE, |
| 126 | insamples->audio->nb_samples); | 126 | insamples->audio->nb_samples); |
| 127 | avfilter_copy_buffer_ref_props(outsamples, insamples); | 127 | avfilter_copy_buffer_ref_props(outsamples, insamples); |
| 128 | 128 | ||
| @@ -141,7 +141,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 12 unmodified lines | |||
| 141 | // save part of input for next round | 141 | // save part of input for next round |
| 142 | memcpy(taps, endin, NUMTAPS * sizeof(*taps)); | 142 | memcpy(taps, endin, NUMTAPS * sizeof(*taps)); |
| 143 | 143 | ||
| 144 | avfilter_filter_samples(outlink, outsamples); | 144 | ff_filter_samples(outlink, outsamples); |
| 145 | avfilter_unref_buffer(insamples); | 145 | avfilter_unref_buffer(insamples); |
| 146 | } | 146 | } |
| 147 | 147 | ||
| @@ -340,7 +340,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 339 unmodified lines | |||
| 340 | { | 340 | { |
| 341 | int n = insamples->audio->nb_samples; | 341 | int n = insamples->audio->nb_samples; |
| 342 | AVFilterLink *const outlink = inlink->dst->outputs[0]; | 342 | AVFilterLink *const outlink = inlink->dst->outputs[0]; |
| 343 | AVFilterBufferRef *outsamples = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, n); | 343 | AVFilterBufferRef *outsamples = ff_get_audio_buffer(outlink, AV_PERM_WRITE, n); |
| 344 | PanContext *pan = inlink->dst->priv; | 344 | PanContext *pan = inlink->dst->priv; |
| 345 | 345 | ||
| 346 | swr_convert(pan->swr, outsamples->data, n, (void *)insamples->data, n); | 346 | swr_convert(pan->swr, outsamples->data, n, (void *)insamples->data, n); |
| @@ -348,7 +348,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 1 unmodified line | |||
| 348 | outsamples->audio->channel_layout = outlink->channel_layout; | 348 | outsamples->audio->channel_layout = outlink->channel_layout; |
| 349 | outsamples->audio->planar = outlink->planar; | 349 | outsamples->audio->planar = outlink->planar; |
| 350 | 350 | ||
| 351 | avfilter_filter_samples(outlink, outsamples); | 351 | ff_filter_samples(outlink, outsamples); |
| 352 | avfilter_unref_buffer(insamples); | 352 | avfilter_unref_buffer(insamples); |
| 353 | } | 353 | } |
| 354 | 354 | ||
| @@ -123,7 +123,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 122 unmodified lines | |||
| 123 | } | 123 | } |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | avfilter_filter_samples(inlink->dst->outputs[0], insamples); | 126 | ff_filter_samples(inlink->dst->outputs[0], insamples); |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | static int query_formats(AVFilterContext *ctx) | 129 | static int query_formats(AVFilterContext *ctx) |
| @@ -163,7 +163,7 @@ AVFilter avfilter_af_silencedetect = { · 33 unmodified lines | |||
| 163 | .inputs = (const AVFilterPad[]) { | 163 | .inputs = (const AVFilterPad[]) { |
| 164 | { .name = "default", | 164 | { .name = "default", |
| 165 | .type = AVMEDIA_TYPE_AUDIO, | 165 | .type = AVMEDIA_TYPE_AUDIO, |
| 166 | .get_audio_buffer = avfilter_null_get_audio_buffer, | 166 | .get_audio_buffer = ff_null_get_audio_buffer, |
| 167 | .filter_samples = filter_samples, }, | 167 | .filter_samples = filter_samples, }, |
| 168 | { .name = NULL } | 168 | { .name = NULL } |
| 169 | }, | 169 | }, |
| @@ -167,7 +167,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 166 unmodified lines | |||
| 167 | } | 167 | } |
| 168 | } | 168 | } |
| 169 | } | 169 | } |
| 170 | avfilter_filter_samples(outlink, insamples); | 170 | ff_filter_samples(outlink, insamples); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | AVFilter avfilter_af_volume = { | 173 | AVFilter avfilter_af_volume = { |
| @@ -205,7 +205,7 @@ static int request_frame(AVFilterLink *outlink) · 204 unmodified lines | |||
| 205 | if (eval->duration >= 0 && t > eval->duration) | 205 | if (eval->duration >= 0 && t > eval->duration) |
| 206 | return AVERROR_EOF; | 206 | return AVERROR_EOF; |
| 207 | 207 | ||
| 208 | samplesref = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, eval->nb_samples); | 208 | samplesref = ff_get_audio_buffer(outlink, AV_PERM_WRITE, eval->nb_samples); |
| 209 | 209 | ||
| 210 | /* evaluate expression for each single sample and for each channel */ | 210 | /* evaluate expression for each single sample and for each channel */ |
| 211 | for (i = 0; i < eval->nb_samples; i++, eval->n++) { | 211 | for (i = 0; i < eval->nb_samples; i++, eval->n++) { |
| @@ -223,7 +223,7 @@ static int request_frame(AVFilterLink *outlink) · 11 unmodified lines | |||
| 223 | samplesref->audio->sample_rate = eval->sample_rate; | 223 | samplesref->audio->sample_rate = eval->sample_rate; |
| 224 | eval->pts += eval->nb_samples; | 224 | eval->pts += eval->nb_samples; |
| 225 | 225 | ||
| 226 | avfilter_filter_samples(outlink, samplesref); | 226 | ff_filter_samples(outlink, samplesref); |
| 227 | 227 | ||
| 228 | return 0; | 228 | return 0; |
| 229 | } | 229 | } |
| @@ -108,13 +108,13 @@ static int request_frame(AVFilterLink *outlink) · 107 unmodified lines | |||
| 108 | AVFilterBufferRef *samplesref; | 108 | AVFilterBufferRef *samplesref; |
| 109 | 109 | ||
| 110 | samplesref = | 110 | samplesref = |
| 111 | avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, null->nb_samples); | 111 | ff_get_audio_buffer(outlink, AV_PERM_WRITE, null->nb_samples); |
| 112 | samplesref->pts = null->pts; | 112 | samplesref->pts = null->pts; |
| 113 | samplesref->pos = -1; | 113 | samplesref->pos = -1; |
| 114 | samplesref->audio->channel_layout = null->channel_layout; | 114 | samplesref->audio->channel_layout = null->channel_layout; |
| 115 | samplesref->audio->sample_rate = outlink->sample_rate; | 115 | samplesref->audio->sample_rate = outlink->sample_rate; |
| 116 | 116 | ||
| 117 | avfilter_filter_samples(outlink, avfilter_ref_buffer(samplesref, ~0)); | 117 | ff_filter_samples(outlink, avfilter_ref_buffer(samplesref, ~0)); |
| 118 | avfilter_unref_buffer(samplesref); | 118 | avfilter_unref_buffer(samplesref); |
| 119 | 119 | ||
| 120 | null->pts += null->nb_samples; | 120 | null->pts += null->nb_samples; |
| @@ -0,0 +1,291 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) Stefano Sabatini | stefasab at gmail.com | ||
| 3 | * Copyright (c) S.N. Hemanth Meenakshisundaram | smeenaks at ucsd.edu | ||
| 4 | * | ||
| 5 | * This file is part of FFmpeg. | ||
| 6 | * | ||
| 7 | * FFmpeg is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with FFmpeg; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "libavutil/avassert.h" | ||
| 23 | #include "libavutil/audioconvert.h" | ||
| 24 | |||
| 25 | #include "audio.h" | ||
| 26 | #include "avfilter.h" | ||
| 27 | #include "internal.h" | ||
| 28 | |||
| 29 | AVFilterBufferRef *ff_null_get_audio_buffer(AVFilterLink *link, int perms, | ||
| 30 | int nb_samples) | ||
| 31 | { | ||
| 32 | return ff_get_audio_buffer(link->dst->outputs[0], perms, nb_samples); | ||
| 33 | } | ||
| 34 | |||
| 35 | AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms, | ||
| 36 | int nb_samples) | ||
| 37 | { | ||
| 38 | AVFilterBufferRef *samplesref = NULL; | ||
| 39 | int linesize[8] = {0}; | ||
| 40 | uint8_t *data[8] = {0}; | ||
| 41 | int ch, nb_channels = av_get_channel_layout_nb_channels(link->channel_layout); | ||
| 42 | |||
| 43 | /* right now we don't support more than 8 channels */ | ||
| 44 | av_assert0(nb_channels <= 8); | ||
| 45 | |||
| 46 | /* Calculate total buffer size, round to multiple of 16 to be SIMD friendly */ | ||
| 47 | if (av_samples_alloc(data, linesize, | ||
| 48 | nb_channels, nb_samples, | ||
| 49 | av_get_alt_sample_fmt(link->format, link->planar), | ||
| 50 | 16) < 0) | ||
| 51 | return NULL; | ||
| 52 | |||
| 53 | for (ch = 1; link->planar && ch < nb_channels; ch++) | ||
| 54 | linesize[ch] = linesize[0]; | ||
| 55 | samplesref = | ||
| 56 | avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms, | ||
| 57 | nb_samples, link->format, | ||
| 58 | link->channel_layout, link->planar); | ||
| 59 | if (!samplesref) { | ||
| 60 | av_free(data[0]); | ||
| 61 | return NULL; | ||
| 62 | } | ||
| 63 | |||
| 64 | return samplesref; | ||
| 65 | } | ||
| 66 | |||
| 67 | static AVFilterBufferRef *ff_default_get_audio_buffer_alt(AVFilterLink *link, int perms, | ||
| 68 | int nb_samples) | ||
| 69 | { | ||
| 70 | AVFilterBufferRef *samplesref = NULL; | ||
| 71 | uint8_t **data; | ||
| 72 | int planar = av_sample_fmt_is_planar(link->format); | ||
| 73 | int nb_channels = av_get_channel_layout_nb_channels(link->channel_layout); | ||
| 74 | int planes = planar ? nb_channels : 1; | ||
| 75 | int linesize; | ||
| 76 | |||
| 77 | if (!(data = av_mallocz(sizeof(*data) * planes))) | ||
| 78 | goto fail; | ||
| 79 | |||
| 80 | if (av_samples_alloc(data, &linesize, nb_channels, nb_samples, link->format, 0) < 0) | ||
| 81 | goto fail; | ||
| 82 | |||
| 83 | samplesref = avfilter_get_audio_buffer_ref_from_arrays_alt(data, linesize, perms, | ||
| 84 | nb_samples, link->format, | ||
| 85 | link->channel_layout); | ||
| 86 | if (!samplesref) | ||
| 87 | goto fail; | ||
| 88 | |||
| 89 | av_freep(&data); | ||
| 90 | |||
| 91 | fail: | ||
| 92 | if (data) | ||
| 93 | av_freep(&data[0]); | ||
| 94 | av_freep(&data); | ||
| 95 | return samplesref; | ||
| 96 | } | ||
| 97 | |||
| 98 | AVFilterBufferRef *ff_get_audio_buffer(AVFilterLink *link, int perms, | ||
| 99 | int nb_samples) | ||
| 100 | { | ||
| 101 | AVFilterBufferRef *ret = NULL; | ||
| 102 | |||
| 103 | if (link->dstpad->get_audio_buffer) | ||
| 104 | ret = link->dstpad->get_audio_buffer(link, perms, nb_samples); | ||
| 105 | |||
| 106 | if (!ret) | ||
| 107 | ret = ff_default_get_audio_buffer(link, perms, nb_samples); | ||
| 108 | |||
| 109 | if (ret) | ||
| 110 | ret->type = AVMEDIA_TYPE_AUDIO; | ||
| 111 | |||
| 112 | return ret; | ||
| 113 | } | ||
| 114 | |||
| 115 | AVFilterBufferRef * | ||
| 116 | avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms, | ||
| 117 | int nb_samples, enum AVSampleFormat sample_fmt, | ||
| 118 | uint64_t channel_layout, int planar) | ||
| 119 | { | ||
| 120 | AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer)); | ||
| 121 | AVFilterBufferRef *samplesref = av_mallocz(sizeof(AVFilterBufferRef)); | ||
| 122 | |||
| 123 | if (!samples || !samplesref) | ||
| 124 | goto fail; | ||
| 125 | |||
| 126 | samplesref->buf = samples; | ||
| 127 | samplesref->buf->free = ff_avfilter_default_free_buffer; | ||
| 128 | if (!(samplesref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps)))) | ||
| 129 | goto fail; | ||
| 130 | |||
| 131 | samplesref->audio->nb_samples = nb_samples; | ||
| 132 | samplesref->audio->channel_layout = channel_layout; | ||
| 133 | samplesref->audio->planar = planar; | ||
| 134 | |||
| 135 | /* make sure the buffer gets read permission or it's useless for output */ | ||
| 136 | samplesref->perms = perms | AV_PERM_READ; | ||
| 137 | |||
| 138 | samples->refcount = 1; | ||
| 139 | samplesref->type = AVMEDIA_TYPE_AUDIO; | ||
| 140 | samplesref->format = sample_fmt; | ||
| 141 | |||
| 142 | memcpy(samples->data, data, sizeof(samples->data)); | ||
| 143 | memcpy(samples->linesize, linesize, sizeof(samples->linesize)); | ||
| 144 | memcpy(samplesref->data, data, sizeof(samplesref->data)); | ||
| 145 | memcpy(samplesref->linesize, linesize, sizeof(samplesref->linesize)); | ||
| 146 | |||
| 147 | return samplesref; | ||
| 148 | |||
| 149 | fail: | ||
| 150 | if (samplesref && samplesref->audio) | ||
| 151 | av_freep(&samplesref->audio); | ||
| 152 | av_freep(&samplesref); | ||
| 153 | av_freep(&samples); | ||
| 154 | return NULL; | ||
| 155 | } | ||
| 156 | |||
| 157 | AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays_alt(uint8_t **data, | ||
| 158 | int linesize,int perms, | ||
| 159 | int nb_samples, | ||
| 160 | enum AVSampleFormat sample_fmt, | ||
| 161 | uint64_t channel_layout) | ||
| 162 | { | ||
| 163 | int planes; | ||
| 164 | AVFilterBuffer *samples = av_mallocz(sizeof(*samples)); | ||
| 165 | AVFilterBufferRef *samplesref = av_mallocz(sizeof(*samplesref)); | ||
| 166 | |||
| 167 | if (!samples || !samplesref) | ||
| 168 | goto fail; | ||
| 169 | |||
| 170 | samplesref->buf = samples; | ||
| 171 | samplesref->buf->free = ff_avfilter_default_free_buffer; | ||
| 172 | if (!(samplesref->audio = av_mallocz(sizeof(*samplesref->audio)))) | ||
| 173 | goto fail; | ||
| 174 | |||
| 175 | samplesref->audio->nb_samples = nb_samples; | ||
| 176 | samplesref->audio->channel_layout = channel_layout; | ||
| 177 | samplesref->audio->planar = av_sample_fmt_is_planar(sample_fmt); | ||
| 178 | |||
| 179 | planes = samplesref->audio->planar ? av_get_channel_layout_nb_channels(channel_layout) : 1; | ||
| 180 | |||
| 181 | /* make sure the buffer gets read permission or it's useless for output */ | ||
| 182 | samplesref->perms = perms | AV_PERM_READ; | ||
| 183 | |||
| 184 | samples->refcount = 1; | ||
| 185 | samplesref->type = AVMEDIA_TYPE_AUDIO; | ||
| 186 | samplesref->format = sample_fmt; | ||
| 187 | |||
| 188 | memcpy(samples->data, data, | ||
| 189 | FFMIN(FF_ARRAY_ELEMS(samples->data), planes)*sizeof(samples->data[0])); | ||
| 190 | memcpy(samplesref->data, samples->data, sizeof(samples->data)); | ||
| 191 | |||
| 192 | samples->linesize[0] = samplesref->linesize[0] = linesize; | ||
| 193 | |||
| 194 | if (planes > FF_ARRAY_ELEMS(samples->data)) { | ||
| 195 | samples-> extended_data = av_mallocz(sizeof(*samples->extended_data) * | ||
| 196 | planes); | ||
| 197 | samplesref->extended_data = av_mallocz(sizeof(*samplesref->extended_data) * | ||
| 198 | planes); | ||
| 199 | |||
| 200 | if (!samples->extended_data || !samplesref->extended_data) | ||
| 201 | goto fail; | ||
| 202 | |||
| 203 | memcpy(samples-> extended_data, data, sizeof(*data)*planes); | ||
| 204 | memcpy(samplesref->extended_data, data, sizeof(*data)*planes); | ||
| 205 | } else { | ||
| 206 | samples->extended_data = samples->data; | ||
| 207 | samplesref->extended_data = samplesref->data; | ||
| 208 | } | ||
| 209 | |||
| 210 | return samplesref; | ||
| 211 | |||
| 212 | fail: | ||
| 213 | if (samples && samples->extended_data != samples->data) | ||
| 214 | av_freep(&samples->extended_data); | ||
| 215 | if (samplesref) { | ||
| 216 | av_freep(&samplesref->audio); | ||
| 217 | if (samplesref->extended_data != samplesref->data) | ||
| 218 | av_freep(&samplesref->extended_data); | ||
| 219 | } | ||
| 220 | av_freep(&samplesref); | ||
| 221 | av_freep(&samples); | ||
| 222 | return NULL; | ||
| 223 | } | ||
| 224 | |||
| 225 | void ff_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) | ||
| 226 | { | ||
| 227 | ff_filter_samples(link->dst->outputs[0], samplesref); | ||
| 228 | } | ||
| 229 | |||
| 230 | /* FIXME: samplesref is same as link->cur_buf. Need to consider removing the redundant parameter. */ | ||
| 231 | void ff_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) | ||
| 232 | { | ||
| 233 | AVFilterLink *outlink = NULL; | ||
| 234 | |||
| 235 | if (inlink->dst->output_count) | ||
| 236 | outlink = inlink->dst->outputs[0]; | ||
| 237 | |||
| 238 | if (outlink) { | ||
| 239 | outlink->out_buf = ff_default_get_audio_buffer(inlink, AV_PERM_WRITE, | ||
| 240 | samplesref->audio->nb_samples); | ||
| 241 | outlink->out_buf->pts = samplesref->pts; | ||
| 242 | outlink->out_buf->audio->sample_rate = samplesref->audio->sample_rate; | ||
| 243 | ff_filter_samples(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); | ||
| 244 | avfilter_unref_buffer(outlink->out_buf); | ||
| 245 | outlink->out_buf = NULL; | ||
| 246 | } | ||
| 247 | avfilter_unref_buffer(samplesref); | ||
| 248 | inlink->cur_buf = NULL; | ||
| 249 | } | ||
| 250 | |||
| 251 | void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) | ||
| 252 | { | ||
| 253 | void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *); | ||
| 254 | AVFilterPad *dst = link->dstpad; | ||
| 255 | int64_t pts; | ||
| 256 | |||
| 257 | FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1); | ||
| 258 | |||
| 259 | if (!(filter_samples = dst->filter_samples)) | ||
| 260 | filter_samples = ff_default_filter_samples; | ||
| 261 | |||
| 262 | /* prepare to copy the samples if the buffer has insufficient permissions */ | ||
| 263 | if ((dst->min_perms & samplesref->perms) != dst->min_perms || | ||
| 264 | dst->rej_perms & samplesref->perms) { | ||
| 265 | int i, planar = av_sample_fmt_is_planar(samplesref->format); | ||
| 266 | int planes = !planar ? 1: | ||
| 267 | av_get_channel_layout_nb_channels(samplesref->audio->channel_layout); | ||
| 268 | |||
| 269 | av_log(link->dst, AV_LOG_DEBUG, | ||
| 270 | "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n", | ||
| 271 | samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms); | ||
| 272 | |||
| 273 | link->cur_buf = ff_default_get_audio_buffer(link, dst->min_perms, | ||
| 274 | samplesref->audio->nb_samples); | ||
| 275 | link->cur_buf->pts = samplesref->pts; | ||
| 276 | link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate; | ||
| 277 | |||
| 278 | /* Copy actual data into new samples buffer */ | ||
| 279 | for (i = 0; samplesref->data[i] && i < 8; i++) | ||
| 280 | memcpy(link->cur_buf->data[i], samplesref->data[i], samplesref->linesize[0]); | ||
| 281 | for (i = 0; i < planes; i++) | ||
| 282 | memcpy(link->cur_buf->extended_data[i], samplesref->extended_data[i], samplesref->linesize[0]); | ||
| 283 | |||
| 284 | avfilter_unref_buffer(samplesref); | ||
| 285 | } else | ||
| 286 | link->cur_buf = samplesref; | ||
| 287 | |||
| 288 | pts = link->cur_buf->pts; | ||
| 289 | filter_samples(link, link->cur_buf); | ||
| 290 | ff_update_link_current_pts(link, pts); | ||
| 291 | } | ||
| @@ -0,0 +1,65 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) Stefano Sabatini | stefasab at gmail.com | ||
| 3 | * Copyright (c) S.N. Hemanth Meenakshisundaram | smeenaks at ucsd.edu | ||
| 4 | * | ||
| 5 | * This file is part of FFmpeg. | ||
| 6 | * | ||
| 7 | * FFmpeg is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with FFmpeg; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | #ifndef AVFILTER_AUDIO_H | ||
| 23 | #define AVFILTER_AUDIO_H | ||
| 24 | |||
| 25 | #include "avfilter.h" | ||
| 26 | |||
| 27 | |||
| 28 | /** default handler for get_audio_buffer() for audio inputs */ | ||
| 29 | AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms, | ||
| 30 | int nb_samples); | ||
| 31 | |||
| 32 | /** get_audio_buffer() handler for filters which simply pass audio along */ | ||
| 33 | AVFilterBufferRef *ff_null_get_audio_buffer(AVFilterLink *link, int perms, | ||
| 34 | int nb_samples); | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Request an audio samples buffer with a specific set of permissions. | ||
| 38 | * | ||
| 39 | * @param link the output link to the filter from which the buffer will | ||
| 40 | * be requested | ||
| 41 | * @param perms the required access permissions | ||
| 42 | * @param nb_samples the number of samples per channel | ||
| 43 | * @return A reference to the samples. This must be unreferenced with | ||
| 44 | * avfilter_unref_buffer when you are finished with it. | ||
| 45 | */ | ||
| 46 | AVFilterBufferRef *ff_get_audio_buffer(AVFilterLink *link, int perms, | ||
| 47 | int nb_samples); | ||
| 48 | |||
| 49 | /** default handler for filter_samples() for audio inputs */ | ||
| 50 | void ff_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); | ||
| 51 | |||
| 52 | /** filter_samples() handler for filters which simply pass audio along */ | ||
| 53 | void ff_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); | ||
| 54 | |||
| 55 | /** | ||
| 56 | * Send a buffer of audio samples to the next filter. | ||
| 57 | * | ||
| 58 | * @param link the output link over which the audio samples are being sent | ||
| 59 | * @param samplesref a reference to the buffer of audio samples being sent. The | ||
| 60 | * receiving filter will free this reference when it no longer | ||
| 61 | * needs it or pass it on to the next filter. | ||
| 62 | */ | ||
| 63 | void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); | ||
| 64 | |||
| 65 | #endif /* AVFILTER_AUDIO_H */ | ||
| @@ -27,6 +27,7 @@ · 26 unmodified lines | |||
| 27 | #include "libavutil/imgutils.h" | 27 | #include "libavutil/imgutils.h" |
| 28 | #include "libavutil/avassert.h" | 28 | #include "libavutil/avassert.h" |
| 29 | #include "libavutil/avstring.h" | 29 | #include "libavutil/avstring.h" |
| 30 | |||
| 30 | #include "avfilter.h" | 31 | #include "avfilter.h" |
| 31 | #include "internal.h" | 32 | #include "internal.h" |
| 32 | 33 | ||
| @@ -410,7 +411,7 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end) · 377 unmodified lines | |||
| 410 | av_dlog(ctx, "]%s", end ? "\n" : ""); | 411 | av_dlog(ctx, "]%s", end ? "\n" : ""); |
| 411 | } | 412 | } |
| 412 | 413 | ||
| 413 | static void ff_dlog_link(void *ctx, AVFilterLink *link, int end) | 414 | void ff_dlog_link(void *ctx, AVFilterLink *link, int end) |
| 414 | { | 415 | { |
| 415 | if (link->type == AVMEDIA_TYPE_VIDEO) { | 416 | if (link->type == AVMEDIA_TYPE_VIDEO) { |
| 416 | av_dlog(ctx, | 417 | av_dlog(ctx, |
| @@ -434,8 +435,6 @@ static void ff_dlog_link(void *ctx, AVFilterLink *link, int end) · 17 unmodified lines | |||
| 434 | } | 435 | } |
| 435 | } | 436 | } |
| 436 | 437 | ||
| 437 | #define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func) | ||
| 438 | |||
| 439 | AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h) | 438 | AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h) |
| 440 | { | 439 | { |
| 441 | AVFilterBufferRef *ret = NULL; | 440 | AVFilterBufferRef *ret = NULL; |
| @@ -501,133 +500,6 @@ fail: · 59 unmodified lines | |||
| 501 | return NULL; | 500 | return NULL; |
| 502 | } | 501 | } |
| 503 | 502 | ||
| 504 | AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, | ||
| 505 | int perms, int nb_samples) | ||
| 506 | { | ||
| 507 | AVFilterBufferRef *ret = NULL; | ||
| 508 | |||
| 509 | if (link->dstpad->get_audio_buffer) | ||
| 510 | ret = link->dstpad->get_audio_buffer(link, perms, nb_samples); | ||
| 511 | |||
| 512 | if (!ret) | ||
| 513 | ret = avfilter_default_get_audio_buffer(link, perms, nb_samples); | ||
| 514 | |||
| 515 | if (ret) | ||
| 516 | ret->type = AVMEDIA_TYPE_AUDIO; | ||
| 517 | |||
| 518 | return ret; | ||
| 519 | } | ||
| 520 | |||
| 521 | AVFilterBufferRef * | ||
| 522 | avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms, | ||
| 523 | int nb_samples, enum AVSampleFormat sample_fmt, | ||
| 524 | uint64_t channel_layout, int planar) | ||
| 525 | { | ||
| 526 | AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer)); | ||
| 527 | AVFilterBufferRef *samplesref = av_mallocz(sizeof(AVFilterBufferRef)); | ||
| 528 | |||
| 529 | if (!samples || !samplesref) | ||
| 530 | goto fail; | ||
| 531 | |||
| 532 | samplesref->buf = samples; | ||
| 533 | samplesref->buf->free = ff_avfilter_default_free_buffer; | ||
| 534 | if (!(samplesref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps)))) | ||
| 535 | goto fail; | ||
| 536 | |||
| 537 | samplesref->audio->nb_samples = nb_samples; | ||
| 538 | samplesref->audio->channel_layout = channel_layout; | ||
| 539 | samplesref->audio->planar = planar; | ||
| 540 | |||
| 541 | /* make sure the buffer gets read permission or it's useless for output */ | ||
| 542 | samplesref->perms = perms | AV_PERM_READ; | ||
| 543 | |||
| 544 | samples->refcount = 1; | ||
| 545 | samplesref->type = AVMEDIA_TYPE_AUDIO; | ||
| 546 | samplesref->format = sample_fmt; | ||
| 547 | |||
| 548 | memcpy(samples->data, data, sizeof(samples->data)); | ||
| 549 | memcpy(samples->linesize, linesize, sizeof(samples->linesize)); | ||
| 550 | memcpy(samplesref->data, data, sizeof(samplesref->data)); | ||
| 551 | memcpy(samplesref->linesize, linesize, sizeof(samplesref->linesize)); | ||
| 552 | |||
| 553 | return samplesref; | ||
| 554 | |||
| 555 | fail: | ||
| 556 | if (samplesref && samplesref->audio) | ||
| 557 | av_freep(&samplesref->audio); | ||
| 558 | av_freep(&samplesref); | ||
| 559 | av_freep(&samples); | ||
| 560 | return NULL; | ||
| 561 | } | ||
| 562 | |||
| 563 | AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays_alt(uint8_t **data, | ||
| 564 | int linesize, int perms, | ||
| 565 | int nb_samples, | ||
| 566 | enum AVSampleFormat sample_fmt, | ||
| 567 | uint64_t channel_layout) | ||
| 568 | { | ||
| 569 | int planes; | ||
| 570 | AVFilterBuffer *samples = av_mallocz(sizeof(*samples)); | ||
| 571 | AVFilterBufferRef *samplesref = av_mallocz(sizeof(*samplesref)); | ||
| 572 | |||
| 573 | if (!samples || !samplesref) | ||
| 574 | goto fail; | ||
| 575 | |||
| 576 | samplesref->buf = samples; | ||
| 577 | samplesref->buf->free = ff_avfilter_default_free_buffer; | ||
| 578 | if (!(samplesref->audio = av_mallocz(sizeof(*samplesref->audio)))) | ||
| 579 | goto fail; | ||
| 580 | |||
| 581 | samplesref->audio->nb_samples = nb_samples; | ||
| 582 | samplesref->audio->channel_layout = channel_layout; | ||
| 583 | samplesref->audio->planar = av_sample_fmt_is_planar(sample_fmt); | ||
| 584 | |||
| 585 | planes = samplesref->audio->planar ? av_get_channel_layout_nb_channels(channel_layout) : 1; | ||
| 586 | |||
| 587 | /* make sure the buffer gets read permission or it's useless for output */ | ||
| 588 | samplesref->perms = perms | AV_PERM_READ; | ||
| 589 | |||
| 590 | samples->refcount = 1; | ||
| 591 | samplesref->type = AVMEDIA_TYPE_AUDIO; | ||
| 592 | samplesref->format = sample_fmt; | ||
| 593 | |||
| 594 | memcpy(samples->data, data, | ||
| 595 | FFMIN(FF_ARRAY_ELEMS(samples->data), planes)*sizeof(samples->data[0])); | ||
| 596 | memcpy(samplesref->data, samples->data, sizeof(samples->data)); | ||
| 597 | |||
| 598 | samples->linesize[0] = samplesref->linesize[0] = linesize; | ||
| 599 | |||
| 600 | if (planes > FF_ARRAY_ELEMS(samples->data)) { | ||
| 601 | samples-> extended_data = av_mallocz(sizeof(*samples->extended_data) * | ||
| 602 | planes); | ||
| 603 | samplesref->extended_data = av_mallocz(sizeof(*samplesref->extended_data) * | ||
| 604 | planes); | ||
| 605 | |||
| 606 | if (!samples->extended_data || !samplesref->extended_data) | ||
| 607 | goto fail; | ||
| 608 | |||
| 609 | memcpy(samples-> extended_data, data, sizeof(*data)*planes); | ||
| 610 | memcpy(samplesref->extended_data, data, sizeof(*data)*planes); | ||
| 611 | } else { | ||
| 612 | samples->extended_data = samples->data; | ||
| 613 | samplesref->extended_data = samplesref->data; | ||
| 614 | } | ||
| 615 | |||
| 616 | return samplesref; | ||
| 617 | |||
| 618 | fail: | ||
| 619 | if (samples && samples->extended_data != samples->data) | ||
| 620 | av_freep(&samples->extended_data); | ||
| 621 | if (samplesref) { | ||
| 622 | av_freep(&samplesref->audio); | ||
| 623 | if (samplesref->extended_data != samplesref->data) | ||
| 624 | av_freep(&samplesref->extended_data); | ||
| 625 | } | ||
| 626 | av_freep(&samplesref); | ||
| 627 | av_freep(&samples); | ||
| 628 | return NULL; | ||
| 629 | } | ||
| 630 | |||
| 631 | int avfilter_request_frame(AVFilterLink *link) | 503 | int avfilter_request_frame(AVFilterLink *link) |
| 632 | { | 504 | { |
| 633 | FF_DPRINTF_START(NULL, request_frame); ff_dlog_link(NULL, link, 1); | 505 | FF_DPRINTF_START(NULL, request_frame); ff_dlog_link(NULL, link, 1); |
| @@ -657,7 +529,7 @@ int avfilter_poll_frame(AVFilterLink *link) · 23 unmodified lines | |||
| 657 | return min; | 529 | return min; |
| 658 | } | 530 | } |
| 659 | 531 | ||
| 660 | static void update_link_current_pts(AVFilterLink *link, int64_t pts) | 532 | void ff_update_link_current_pts(AVFilterLink *link, int64_t pts) |
| 661 | { | 533 | { |
| 662 | if (pts == AV_NOPTS_VALUE) | 534 | if (pts == AV_NOPTS_VALUE) |
| 663 | return; | 535 | return; |
| @@ -706,7 +578,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 42 unmodified lines | |||
| 706 | } | 578 | } |
| 707 | 579 | ||
| 708 | start_frame(link, link->cur_buf); | 580 | start_frame(link, link->cur_buf); |
| 709 | update_link_current_pts(link, link->cur_buf->pts); | 581 | ff_update_link_current_pts(link, link->cur_buf->pts); |
| 710 | } | 582 | } |
| 711 | 583 | ||
| 712 | void avfilter_end_frame(AVFilterLink *link) | 584 | void avfilter_end_frame(AVFilterLink *link) |
| @@ -778,44 +650,6 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha · 65 unmodified lines | |||
| 778 | return AVERROR(ENOSYS); | 650 | return AVERROR(ENOSYS); |
| 779 | } | 651 | } |
| 780 | 652 | ||
| 781 | void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) | ||
| 782 | { | ||
| 783 | void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *); | ||
| 784 | AVFilterPad *dst = link->dstpad; | ||
| 785 | int i; | ||
| 786 | int64_t pts; | ||
| 787 | |||
| 788 | FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1); | ||
| 789 | |||
| 790 | if (!(filter_samples = dst->filter_samples)) | ||
| 791 | filter_samples = avfilter_default_filter_samples; | ||
| 792 | |||
| 793 | /* prepare to copy the samples if the buffer has insufficient permissions */ | ||
| 794 | if ((dst->min_perms & samplesref->perms) != dst->min_perms || | ||
| 795 | dst->rej_perms & samplesref->perms) { | ||
| 796 | |||
| 797 | av_log(link->dst, AV_LOG_DEBUG, | ||
| 798 | "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n", | ||
| 799 | samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms); | ||
| 800 | |||
| 801 | link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms, | ||
| 802 | samplesref->audio->nb_samples); | ||
| 803 | link->cur_buf->pts = samplesref->pts; | ||
| 804 | link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate; | ||
| 805 | |||
| 806 | /* Copy actual data into new samples buffer */ | ||
| 807 | for (i = 0; samplesref->data[i] && i < 8; i++) | ||
| 808 | memcpy(link->cur_buf->data[i], samplesref->data[i], samplesref->linesize[0]); | ||
| 809 | |||
| 810 | avfilter_unref_buffer(samplesref); | ||
| 811 | } else | ||
| 812 | link->cur_buf = samplesref; | ||
| 813 | |||
| 814 | pts = link->cur_buf->pts; | ||
| 815 | filter_samples(link, link->cur_buf); | ||
| 816 | update_link_current_pts(link, pts); | ||
| 817 | } | ||
| 818 | |||
| 819 | #define MAX_REGISTERED_AVFILTERS_NB 128 | 653 | #define MAX_REGISTERED_AVFILTERS_NB 128 |
| 820 | 654 | ||
| 821 | static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1]; | 655 | static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1]; |
| @@ -430,7 +430,8 @@ struct AVFilterPad { · 429 unmodified lines | |||
| 430 | * | 430 | * |
| 431 | * Input audio pads only. | 431 | * Input audio pads only. |
| 432 | */ | 432 | */ |
| 433 | AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms, int nb_samples); | 433 | AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms, |
| 434 | int nb_samples); | ||
| 434 | 435 | ||
| 435 | /** | 436 | /** |
| 436 | * Callback called after the slices of a frame are completely sent. If | 437 | * Callback called after the slices of a frame are completely sent. If |
| @@ -508,16 +509,10 @@ void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir · 71 unmodified lines | |||
| 508 | /** default handler for end_frame() for video inputs */ | 509 | /** default handler for end_frame() for video inputs */ |
| 509 | void avfilter_default_end_frame(AVFilterLink *link); | 510 | void avfilter_default_end_frame(AVFilterLink *link); |
| 510 | 511 | ||
| 511 | /** default handler for filter_samples() for audio inputs */ | ||
| 512 | void avfilter_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); | ||
| 513 | |||
| 514 | /** default handler for get_video_buffer() for video inputs */ | 512 | /** default handler for get_video_buffer() for video inputs */ |
| 515 | AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, | 513 | AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, |
| 516 | int perms, int w, int h); | 514 | int perms, int w, int h); |
| 517 | 515 | ||
| 518 | /** default handler for get_audio_buffer() for audio inputs */ | ||
| 519 | AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, | ||
| 520 | int perms, int nb_samples); | ||
| 521 | 516 | ||
| 522 | /** | 517 | /** |
| 523 | * Helpers for query_formats() which set all links to the same list of | 518 | * Helpers for query_formats() which set all links to the same list of |
| @@ -541,17 +536,10 @@ void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); · 17 unmodified lines | |||
| 541 | /** end_frame() handler for filters which simply pass video along */ | 536 | /** end_frame() handler for filters which simply pass video along */ |
| 542 | void avfilter_null_end_frame(AVFilterLink *link); | 537 | void avfilter_null_end_frame(AVFilterLink *link); |
| 543 | 538 | ||
| 544 | /** filter_samples() handler for filters which simply pass audio along */ | ||
| 545 | void avfilter_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); | ||
| 546 | |||
| 547 | /** get_video_buffer() handler for filters which simply pass video along */ | 539 | /** get_video_buffer() handler for filters which simply pass video along */ |
| 548 | AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, | 540 | AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, |
| 549 | int perms, int w, int h); | 541 | int perms, int w, int h); |
| 550 | 542 | ||
| 551 | /** get_audio_buffer() handler for filters which simply pass audio along */ | ||
| 552 | AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, | ||
| 553 | int perms, int nb_samples); | ||
| 554 | |||
| 555 | /** | 543 | /** |
| 556 | * Filter definition. This defines the pads a filter contains, and all the | 544 | * Filter definition. This defines the pads a filter contains, and all the |
| 557 | * callback functions used to interact with the filter. | 545 | * callback functions used to interact with the filter. |
| @@ -665,7 +653,7 @@ struct AVFilterLink { · 107 unmodified lines | |||
| 665 | AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio | 653 | AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio |
| 666 | /* These parameters apply only to audio */ | 654 | /* These parameters apply only to audio */ |
| 667 | uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/audioconvert.h) | 655 | uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/audioconvert.h) |
| 668 | #if LIBAVFILTER_VERSION_MAJOR < 3 | 656 | #if FF_API_SAMPLERATE64 |
| 669 | int64_t sample_rate; ///< samples per second | 657 | int64_t sample_rate; ///< samples per second |
| 670 | #else | 658 | #else |
| 671 | int sample_rate; ///< samples per second | 659 | int sample_rate; ///< samples per second |
| @@ -790,19 +778,6 @@ AVFilterBufferRef * · 118 unmodified lines | |||
| 790 | avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms, | 778 | avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms, |
| 791 | int w, int h, enum PixelFormat format); | 779 | int w, int h, enum PixelFormat format); |
| 792 | 780 | ||
| 793 | /** | ||
| 794 | * Request an audio samples buffer with a specific set of permissions. | ||
| 795 | * | ||
| 796 | * @param link the output link to the filter from which the buffer will | ||
| 797 | * be requested | ||
| 798 | * @param perms the required access permissions | ||
| 799 | * @param nb_samples the number of samples per channel | ||
| 800 | * @return A reference to the samples. This must be unreferenced with | ||
| 801 | * avfilter_unref_buffer when you are finished with it. | ||
| 802 | */ | ||
| 803 | AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, | ||
| 804 | int nb_samples); | ||
| 805 | |||
| 806 | /** | 781 | /** |
| 807 | * Create an audio buffer reference wrapped around an already | 782 | * Create an audio buffer reference wrapped around an already |
| 808 | * allocated samples buffer. | 783 | * allocated samples buffer. |
| @@ -904,17 +879,7 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); · 95 unmodified lines | |||
| 904 | */ | 879 | */ |
| 905 | int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags); | 880 | int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags); |
| 906 | 881 | ||
| 907 | /** | 882 | /** Initialize the filter system. Register all builtin filters. */ |
| 908 | * Send a buffer of audio samples to the next filter. | ||
| 909 | * | ||
| 910 | * @param link the output link over which the audio samples are being sent | ||
| 911 | * @param samplesref a reference to the buffer of audio samples being sent. The | ||
| 912 | * receiving filter will free this reference when it no longer | ||
| 913 | * needs it or pass it on to the next filter. | ||
| 914 | */ | ||
| 915 | void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); | ||
| 916 | |||
| 917 | /** Initialize the filter system. Register all built-in filters. */ | ||
| 918 | void avfilter_register_all(void); | 883 | void avfilter_register_all(void); |
| 919 | 884 | ||
| 920 | /** Uninitialize the filter system. Unregister all filters. */ | 885 | /** Uninitialize the filter system. Unregister all filters. */ |
| @@ -1024,4 +989,6 @@ static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index, · 103 unmodified lines | |||
| 1024 | &f->output_pads, &f->outputs, p); | 989 | &f->output_pads, &f->outputs, p); |
| 1025 | } | 990 | } |
| 1026 | 991 | ||
| 992 | #include "audio.h" | ||
| 993 | |||
| 1027 | #endif /* AVFILTER_AVFILTER_H */ | 994 | #endif /* AVFILTER_AVFILTER_H */ |
| @@ -23,6 +23,7 @@ · 22 unmodified lines | |||
| 23 | #include "libavutil/audioconvert.h" | 23 | #include "libavutil/audioconvert.h" |
| 24 | #include "libavutil/imgutils.h" | 24 | #include "libavutil/imgutils.h" |
| 25 | #include "libavutil/samplefmt.h" | 25 | #include "libavutil/samplefmt.h" |
| 26 | |||
| 26 | #include "avfilter.h" | 27 | #include "avfilter.h" |
| 27 | #include "internal.h" | 28 | #include "internal.h" |
| 28 | 29 | ||
| @@ -87,38 +88,6 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per · 58 unmodified lines | |||
| 87 | return picref; | 88 | return picref; |
| 88 | } | 89 | } |
| 89 | 90 | ||
| 90 | AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms, | ||
| 91 | int nb_samples) | ||
| 92 | { | ||
| 93 | AVFilterBufferRef *samplesref = NULL; | ||
| 94 | int linesize[8] = {0}; | ||
| 95 | uint8_t *data[8] = {0}; | ||
| 96 | int ch, nb_channels = av_get_channel_layout_nb_channels(link->channel_layout); | ||
| 97 | |||
| 98 | /* right now we don't support more than 8 channels */ | ||
| 99 | av_assert0(nb_channels <= 8); | ||
| 100 | |||
| 101 | /* Calculate total buffer size, round to multiple of 16 to be SIMD friendly */ | ||
| 102 | if (av_samples_alloc(data, linesize, | ||
| 103 | nb_channels, nb_samples, | ||
| 104 | av_get_alt_sample_fmt(link->format, link->planar), | ||
| 105 | 16) < 0) | ||
| 106 | return NULL; | ||
| 107 | |||
| 108 | for (ch = 1; link->planar && ch < nb_channels; ch++) | ||
| 109 | linesize[ch] = linesize[0]; | ||
| 110 | samplesref = | ||
| 111 | avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms, | ||
| 112 | nb_samples, link->format, | ||
| 113 | link->channel_layout, link->planar); | ||
| 114 | if (!samplesref) { | ||
| 115 | av_free(data[0]); | ||
| 116 | return NULL; | ||
| 117 | } | ||
| 118 | |||
| 119 | return samplesref; | ||
| 120 | } | ||
| 121 | |||
| 122 | void avfilter_default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) | 91 | void avfilter_default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
| 123 | { | 92 | { |
| 124 | AVFilterLink *outlink = NULL; | 93 | AVFilterLink *outlink = NULL; |
| @@ -163,27 +132,6 @@ void avfilter_default_end_frame(AVFilterLink *inlink) · 38 unmodified lines | |||
| 163 | } | 132 | } |
| 164 | } | 133 | } |
| 165 | 134 | ||
| 166 | /* FIXME: samplesref is same as link->cur_buf. Need to consider removing the redundant parameter. */ | ||
| 167 | void avfilter_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) | ||
| 168 | { | ||
| 169 | AVFilterLink *outlink = NULL; | ||
| 170 | |||
| 171 | if (inlink->dst->output_count) | ||
| 172 | outlink = inlink->dst->outputs[0]; | ||
| 173 | |||
| 174 | if (outlink) { | ||
| 175 | outlink->out_buf = avfilter_default_get_audio_buffer(inlink, AV_PERM_WRITE, | ||
| 176 | samplesref->audio->nb_samples); | ||
| 177 | outlink->out_buf->pts = samplesref->pts; | ||
| 178 | outlink->out_buf->audio->sample_rate = samplesref->audio->sample_rate; | ||
| 179 | avfilter_filter_samples(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); | ||
| 180 | avfilter_unref_buffer(outlink->out_buf); | ||
| 181 | outlink->out_buf = NULL; | ||
| 182 | } | ||
| 183 | avfilter_unref_buffer(samplesref); | ||
| 184 | inlink->cur_buf = NULL; | ||
| 185 | } | ||
| 186 | |||
| 187 | static void set_common_formats(AVFilterContext *ctx, AVFilterFormats *fmts, | 135 | static void set_common_formats(AVFilterContext *ctx, AVFilterFormats *fmts, |
| 188 | enum AVMediaType type, int offin, int offout) | 136 | enum AVMediaType type, int offin, int offout) |
| 189 | { | 137 | { |
| @@ -258,18 +206,7 @@ void avfilter_null_end_frame(AVFilterLink *link) · 68 unmodified lines | |||
| 258 | avfilter_end_frame(link->dst->outputs[0]); | 206 | avfilter_end_frame(link->dst->outputs[0]); |
| 259 | } | 207 | } |
| 260 | 208 | ||
| 261 | void avfilter_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) | ||
| 262 | { | ||
| 263 | avfilter_filter_samples(link->dst->outputs[0], samplesref); | ||
| 264 | } | ||
| 265 | |||
| 266 | AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h) | 209 | AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h) |
| 267 | { | 210 | { |
| 268 | return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h); | 211 | return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h); |
| 269 | } | 212 | } |
| 270 | |||
| 271 | AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms, | ||
| 272 | int nb_samples) | ||
| 273 | { | ||
| 274 | return avfilter_get_audio_buffer(link->dst->outputs[0], perms, nb_samples); | ||
| 275 | } | ||
| @@ -149,4 +149,10 @@ static inline void ff_null_start_frame_keep_ref(AVFilterLink *inlink, · 148 unmodified lines | |||
| 149 | avfilter_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0)); | 149 | avfilter_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0)); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | void ff_update_link_current_pts(AVFilterLink *link, int64_t pts); | ||
| 153 | |||
| 154 | #define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func) | ||
| 155 | |||
| 156 | void ff_dlog_link(void *ctx, AVFilterLink *link, int end); | ||
| 157 | |||
| 152 | #endif /* AVFILTER_INTERNAL_H */ | 158 | #endif /* AVFILTER_INTERNAL_H */ |
| @@ -297,7 +297,7 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx, · 296 unmodified lines | |||
| 297 | break; | 297 | break; |
| 298 | 298 | ||
| 299 | case AVMEDIA_TYPE_AUDIO: | 299 | case AVMEDIA_TYPE_AUDIO: |
| 300 | buf = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, | 300 | buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE, |
| 301 | ref->audio->nb_samples); | 301 | ref->audio->nb_samples); |
| 302 | channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout); | 302 | channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout); |
| 303 | data_size = av_samples_get_buffer_size(NULL, channels, | 303 | data_size = av_samples_get_buffer_size(NULL, channels, |
| @@ -562,7 +562,7 @@ static int request_frame(AVFilterLink *link) · 258 unmodified lines | |||
| 562 | avfilter_unref_buffer(buf); | 562 | avfilter_unref_buffer(buf); |
| 563 | break; | 563 | break; |
| 564 | case AVMEDIA_TYPE_AUDIO: | 564 | case AVMEDIA_TYPE_AUDIO: |
| 565 | avfilter_filter_samples(link, avfilter_ref_buffer(buf, ~0)); | 565 | ff_filter_samples(link, avfilter_ref_buffer(buf, ~0)); |
| 566 | avfilter_unref_buffer(buf); | 566 | avfilter_unref_buffer(buf); |
| 567 | break; | 567 | break; |
| 568 | default: | 568 | default: |
| @@ -437,7 +437,7 @@ static int amovie_get_samples(AVFilterLink *outlink) · 436 unmodified lines | |||
| 437 | if (data_size < 0) | 437 | if (data_size < 0) |
| 438 | return data_size; | 438 | return data_size; |
| 439 | movie->samplesref = | 439 | movie->samplesref = |
| 440 | avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, nb_samples); | 440 | ff_get_audio_buffer(outlink, AV_PERM_WRITE, nb_samples); |
| 441 | memcpy(movie->samplesref->data[0], movie->frame->data[0], data_size); | 441 | memcpy(movie->samplesref->data[0], movie->frame->data[0], data_size); |
| 442 | movie->samplesref->pts = movie->pkt.pts; | 442 | movie->samplesref->pts = movie->pkt.pts; |
| 443 | movie->samplesref->pos = movie->pkt.pos; | 443 | movie->samplesref->pos = movie->pkt.pos; |
| @@ -463,7 +463,7 @@ static int amovie_request_frame(AVFilterLink *outlink) · 19 unmodified lines | |||
| 463 | return ret; | 463 | return ret; |
| 464 | } while (!movie->samplesref); | 464 | } while (!movie->samplesref); |
| 465 | 465 | ||
| 466 | avfilter_filter_samples(outlink, avfilter_ref_buffer(movie->samplesref, ~0)); | 466 | ff_filter_samples(outlink, avfilter_ref_buffer(movie->samplesref, ~0)); |
| 467 | avfilter_unref_buffer(movie->samplesref); | 467 | avfilter_unref_buffer(movie->samplesref); |
| 468 | movie->samplesref = NULL; | 468 | movie->samplesref = NULL; |
| 469 | 469 | ||
| @@ -47,5 +47,8 @@ · 46 unmodified lines | |||
| 47 | #ifndef FF_API_GRAPH_AVCLASS | 47 | #ifndef FF_API_GRAPH_AVCLASS |
| 48 | #define FF_API_GRAPH_AVCLASS (LIBAVFILTER_VERSION_MAJOR > 2) | 48 | #define FF_API_GRAPH_AVCLASS (LIBAVFILTER_VERSION_MAJOR > 2) |
| 49 | #endif | 49 | #endif |
| 50 | #ifndef FF_API_SAMPLERATE64 | ||
| 51 | #define FF_API_SAMPLERATE64 (LIBAVFILTER_VERSION_MAJOR < 3) | ||
| 52 | #endif | ||
| 50 | 53 | ||
| 51 | #endif // AVFILTER_VERSION_H | 54 | #endif // AVFILTER_VERSION_H |
| @@ -1051,7 +1051,7 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 1050 unmodified lines | |||
| 1051 | return AVERROR_INVALIDDATA; | 1051 | return AVERROR_INVALIDDATA; |
| 1052 | 1052 | ||
| 1053 | if (atom.size >= 10) { | 1053 | if (atom.size >= 10) { |
| 1054 | // Broken files created by legacy versions of Libav and FFmpeg will | 1054 | // Broken files created by legacy versions of libavformat will |
| 1055 | // wrap a whole fiel atom inside of a glbl atom. | 1055 | // wrap a whole fiel atom inside of a glbl atom. |
| 1056 | unsigned size = avio_rb32(pb); | 1056 | unsigned size = avio_rb32(pb); |
| 1057 | unsigned type = avio_rl32(pb); | 1057 | unsigned type = avio_rl32(pb); |
| @@ -44,6 +44,8 @@ · 43 unmodified lines | |||
| 44 | 44 | ||
| 45 | #define APP_MAX_LENGTH 128 | 45 | #define APP_MAX_LENGTH 128 |
| 46 | #define PLAYPATH_MAX_LENGTH 256 | 46 | #define PLAYPATH_MAX_LENGTH 256 |
| 47 | #define TCURL_MAX_LENGTH 512 | ||
| 48 | #define FLASHVER_MAX_LENGTH 64 | ||
| 47 | 49 | ||
| 48 | /** RTMP protocol handler state */ | 50 | /** RTMP protocol handler state */ |
| 49 | typedef enum { | 51 | typedef enum { |
| @@ -82,6 +84,9 @@ typedef struct RTMPContext { · 32 unmodified lines | |||
| 82 | int flv_header_bytes; ///< number of initialized bytes in flv_header | 84 | int flv_header_bytes; ///< number of initialized bytes in flv_header |
| 83 | int nb_invokes; ///< keeps track of invoke messages | 85 | int nb_invokes; ///< keeps track of invoke messages |
| 84 | int create_stream_invoke; ///< invoke id for the create stream command | 86 | int create_stream_invoke; ///< invoke id for the create stream command |
| 87 | char* tcurl; ///< url of the target stream | ||
| 88 | char* flashver; ///< version of the flash plugin | ||
| 89 | char* swfurl; ///< url of the swf player | ||
| 85 | } RTMPContext; | 90 | } RTMPContext; |
| 86 | 91 | ||
| 87 | #define PLAYER_KEY_OPEN_PART_LEN 30 ///< length of partial key used for first client digest signing | 92 | #define PLAYER_KEY_OPEN_PART_LEN 30 ///< length of partial key used for first client digest signing |
| @@ -110,35 +115,34 @@ static const uint8_t rtmp_server_key[] = { · 22 unmodified lines | |||
| 110 | /** | 115 | /** |
| 111 | * Generate 'connect' call and send it to the server. | 116 | * Generate 'connect' call and send it to the server. |
| 112 | */ | 117 | */ |
| 113 | static void gen_connect(URLContext *s, RTMPContext *rt, const char *proto, | 118 | static void gen_connect(URLContext *s, RTMPContext *rt) |
| 114 | const char *host, int port) | ||
| 115 | { | 119 | { |
| 116 | RTMPPacket pkt; | 120 | RTMPPacket pkt; |
| 117 | uint8_t ver[64], *p; | 121 | uint8_t *p; |
| 118 | char tcurl[512]; | ||
| 119 | 122 | ||
| 120 | ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 4096); | 123 | ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 4096); |
| 121 | p = pkt.data; | 124 | p = pkt.data; |
| 122 | 125 | ||
| 123 | ff_url_join(tcurl, sizeof(tcurl), proto, NULL, host, port, "/%s", rt->app); | ||
| 124 | ff_amf_write_string(&p, "connect"); | 126 | ff_amf_write_string(&p, "connect"); |
| 125 | ff_amf_write_number(&p, ++rt->nb_invokes); | 127 | ff_amf_write_number(&p, ++rt->nb_invokes); |
| 126 | ff_amf_write_object_start(&p); | 128 | ff_amf_write_object_start(&p); |
| 127 | ff_amf_write_field_name(&p, "app"); | 129 | ff_amf_write_field_name(&p, "app"); |
| 128 | ff_amf_write_string(&p, rt->app); | 130 | ff_amf_write_string(&p, rt->app); |
| 129 | 131 | ||
| 130 | if (rt->is_input) { | 132 | if (!rt->is_input) { |
| 131 | snprintf(ver, sizeof(ver), "%s %d,%d,%d,%d", RTMP_CLIENT_PLATFORM, RTMP_CLIENT_VER1, | ||
| 132 | RTMP_CLIENT_VER2, RTMP_CLIENT_VER3, RTMP_CLIENT_VER4); | ||
| 133 | } else { | ||
| 134 | snprintf(ver, sizeof(ver), "FMLE/3.0 (compatible; %s)", LIBAVFORMAT_IDENT); | ||
| 135 | ff_amf_write_field_name(&p, "type"); | 133 | ff_amf_write_field_name(&p, "type"); |
| 136 | ff_amf_write_string(&p, "nonprivate"); | 134 | ff_amf_write_string(&p, "nonprivate"); |
| 137 | } | 135 | } |
| 138 | ff_amf_write_field_name(&p, "flashVer"); | 136 | ff_amf_write_field_name(&p, "flashVer"); |
| 139 | ff_amf_write_string(&p, ver); | 137 | ff_amf_write_string(&p, rt->flashver); |
| 138 | |||
| 139 | if (rt->swfurl) { | ||
| 140 | ff_amf_write_field_name(&p, "swfUrl"); | ||
| 141 | ff_amf_write_string(&p, rt->swfurl); | ||
| 142 | } | ||
| 143 | |||
| 140 | ff_amf_write_field_name(&p, "tcUrl"); | 144 | ff_amf_write_field_name(&p, "tcUrl"); |
| 141 | ff_amf_write_string(&p, tcurl); | 145 | ff_amf_write_string(&p, rt->tcurl); |
| 142 | if (rt->is_input) { | 146 | if (rt->is_input) { |
| 143 | ff_amf_write_field_name(&p, "fpad"); | 147 | ff_amf_write_field_name(&p, "fpad"); |
| 144 | ff_amf_write_bool(&p, 0); | 148 | ff_amf_write_bool(&p, 0); |
| @@ -368,6 +372,25 @@ static void gen_server_bw(URLContext *s, RTMPContext *rt) · 223 unmodified lines | |||
| 368 | ff_rtmp_packet_destroy(&pkt); | 372 | ff_rtmp_packet_destroy(&pkt); |
| 369 | } | 373 | } |
| 370 | 374 | ||
| 375 | /** | ||
| 376 | * Generate check bandwidth message and send it to the server. | ||
| 377 | */ | ||
| 378 | static void gen_check_bw(URLContext *s, RTMPContext *rt) | ||
| 379 | { | ||
| 380 | RTMPPacket pkt; | ||
| 381 | uint8_t *p; | ||
| 382 | |||
| 383 | ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 21); | ||
| 384 | |||
| 385 | p = pkt.data; | ||
| 386 | ff_amf_write_string(&p, "_checkbw"); | ||
| 387 | ff_amf_write_number(&p, ++rt->nb_invokes); | ||
| 388 | ff_amf_write_null(&p); | ||
| 389 | |||
| 390 | ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]); | ||
| 391 | ff_rtmp_packet_destroy(&pkt); | ||
| 392 | } | ||
| 393 | |||
| 371 | /** | 394 | /** |
| 372 | * Generate report on bytes read so far and send it to the server. | 395 | * Generate report on bytes read so far and send it to the server. |
| 373 | */ | 396 | */ |
| @@ -687,6 +710,8 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) · 313 unmodified lines | |||
| 687 | if (!t && !strcmp(tmpstr, "NetStream.Play.Stop")) rt->state = STATE_STOPPED; | 710 | if (!t && !strcmp(tmpstr, "NetStream.Play.Stop")) rt->state = STATE_STOPPED; |
| 688 | if (!t && !strcmp(tmpstr, "NetStream.Play.UnpublishNotify")) rt->state = STATE_STOPPED; | 711 | if (!t && !strcmp(tmpstr, "NetStream.Play.UnpublishNotify")) rt->state = STATE_STOPPED; |
| 689 | if (!t && !strcmp(tmpstr, "NetStream.Publish.Start")) rt->state = STATE_PUBLISHING; | 712 | if (!t && !strcmp(tmpstr, "NetStream.Publish.Start")) rt->state = STATE_PUBLISHING; |
| 713 | } else if (!memcmp(pkt->data, "\002\000\010onBWDone", 11)) { | ||
| 714 | gen_check_bw(s, rt); | ||
| 690 | } | 715 | } |
| 691 | break; | 716 | break; |
| 692 | } | 717 | } |
| @@ -910,13 +935,31 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) · 217 unmodified lines | |||
| 910 | strncat(rt->playpath, fname, PLAYPATH_MAX_LENGTH - 5); | 935 | strncat(rt->playpath, fname, PLAYPATH_MAX_LENGTH - 5); |
| 911 | } | 936 | } |
| 912 | 937 | ||
| 938 | if (!rt->tcurl) { | ||
| 939 | rt->tcurl = av_malloc(TCURL_MAX_LENGTH); | ||
| 940 | ff_url_join(rt->tcurl, TCURL_MAX_LENGTH, proto, NULL, hostname, | ||
| 941 | port, "/%s", rt->app); | ||
| 942 | } | ||
| 943 | |||
| 944 | if (!rt->flashver) { | ||
| 945 | rt->flashver = av_malloc(FLASHVER_MAX_LENGTH); | ||
| 946 | if (rt->is_input) { | ||
| 947 | snprintf(rt->flashver, FLASHVER_MAX_LENGTH, "%s %d,%d,%d,%d", | ||
| 948 | RTMP_CLIENT_PLATFORM, RTMP_CLIENT_VER1, RTMP_CLIENT_VER2, | ||
| 949 | RTMP_CLIENT_VER3, RTMP_CLIENT_VER4); | ||
| 950 | } else { | ||
| 951 | snprintf(rt->flashver, FLASHVER_MAX_LENGTH, | ||
| 952 | "FMLE/3.0 (compatible; %s)", LIBAVFORMAT_IDENT); | ||
| 953 | } | ||
| 954 | } | ||
| 955 | |||
| 913 | rt->client_report_size = 1048576; | 956 | rt->client_report_size = 1048576; |
| 914 | rt->bytes_read = 0; | 957 | rt->bytes_read = 0; |
| 915 | rt->last_bytes_read = 0; | 958 | rt->last_bytes_read = 0; |
| 916 | 959 | ||
| 917 | av_log(s, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n", | 960 | av_log(s, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n", |
| 918 | proto, path, rt->app, rt->playpath); | 961 | proto, path, rt->app, rt->playpath); |
| 919 | gen_connect(s, rt, proto, hostname, port); | 962 | gen_connect(s, rt); |
| 920 | 963 | ||
| 921 | do { | 964 | do { |
| 922 | ret = get_packet(s, 1); | 965 | ret = get_packet(s, 1); |
| @@ -1052,11 +1095,14 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size) · 129 unmodified lines | |||
| 1052 | 1095 | ||
| 1053 | static const AVOption rtmp_options[] = { | 1096 | static const AVOption rtmp_options[] = { |
| 1054 | {"rtmp_app", "Name of application to connect to on the RTMP server", OFFSET(app), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, | 1097 | {"rtmp_app", "Name of application to connect to on the RTMP server", OFFSET(app), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, |
| 1098 | {"rtmp_flashver", "Version of the Flash plugin used to run the SWF player.", OFFSET(flashver), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, | ||
| 1055 | {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), AV_OPT_TYPE_INT, {-2}, INT_MIN, INT_MAX, DEC, "rtmp_live"}, | 1099 | {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), AV_OPT_TYPE_INT, {-2}, INT_MIN, INT_MAX, DEC, "rtmp_live"}, |
| 1056 | {"any", "both", 0, AV_OPT_TYPE_CONST, {-2}, 0, 0, DEC, "rtmp_live"}, | 1100 | {"any", "both", 0, AV_OPT_TYPE_CONST, {-2}, 0, 0, DEC, "rtmp_live"}, |
| 1057 | {"live", "live stream", 0, AV_OPT_TYPE_CONST, {-1}, 0, 0, DEC, "rtmp_live"}, | 1101 | {"live", "live stream", 0, AV_OPT_TYPE_CONST, {-1}, 0, 0, DEC, "rtmp_live"}, |
| 1058 | {"recorded", "recorded stream", 0, AV_OPT_TYPE_CONST, {0}, 0, 0, DEC, "rtmp_live"}, | 1102 | {"recorded", "recorded stream", 0, AV_OPT_TYPE_CONST, {0}, 0, 0, DEC, "rtmp_live"}, |
| 1059 | {"rtmp_playpath", "Stream identifier to play or to publish", OFFSET(playpath), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, | 1103 | {"rtmp_playpath", "Stream identifier to play or to publish", OFFSET(playpath), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, |
| 1104 | {"rtmp_swfurl", "URL of the SWF player. By default no value will be sent", OFFSET(swfurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, | ||
| 1105 | {"rtmp_tcurl", "URL of the target stream. Defaults to rtmp://host[:port]/app.", OFFSET(tcurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, | ||
| 1060 | { NULL }, | 1106 | { NULL }, |
| 1061 | }; | 1107 | }; |
| 1062 | 1108 | ||
| @@ -227,7 +227,7 @@ static int sctp_open(URLContext *h, const char *uri, int flags) · 226 unmodified lines | |||
| 227 | if (s->max_streams) { | 227 | if (s->max_streams) { |
| 228 | initparams.sinit_max_instreams = s->max_streams; | 228 | initparams.sinit_max_instreams = s->max_streams; |
| 229 | initparams.sinit_num_ostreams = s->max_streams; | 229 | initparams.sinit_num_ostreams = s->max_streams; |
| 230 | if (setsockopt(fd, SOL_SCTP, SCTP_INITMSG, &initparams, | 230 | if (setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &initparams, |
| 231 | sizeof(initparams)) < 0) | 231 | sizeof(initparams)) < 0) |
| 232 | av_log(h, AV_LOG_ERROR, | 232 | av_log(h, AV_LOG_ERROR, |
| 233 | "SCTP ERROR: Unable to initialize socket max streams %d\n", | 233 | "SCTP ERROR: Unable to initialize socket max streams %d\n", |
| @@ -54,26 +54,24 @@ cglobal conv_fltp_to_flt_6ch, 2,8,7, dst, src, src1, src2, src3, src4, src5, len · 53 unmodified lines | |||
| 54 | mova m3, [srcq+src3q] | 54 | mova m3, [srcq+src3q] |
| 55 | mova m4, [srcq+src4q] | 55 | mova m4, [srcq+src4q] |
| 56 | mova m5, [srcq+src5q] | 56 | mova m5, [srcq+src5q] |
| 57 | %if cpuflag(sse) | 57 | %if cpuflag(sse4) |
| 58 | SBUTTERFLYPS 0, 1, 6 | 58 | SBUTTERFLYPS 0, 1, 6 |
| 59 | SBUTTERFLYPS 2, 3, 6 | 59 | SBUTTERFLYPS 2, 3, 6 |
| 60 | SBUTTERFLYPS 4, 5, 6 | 60 | SBUTTERFLYPS 4, 5, 6 |
| 61 | 61 | ||
| 62 | movaps m6, m4 | 62 | blendps m6, m4, m0, 1100b |
| 63 | shufps m4, m0, q3210 | ||
| 64 | movlhps m0, m2 | 63 | movlhps m0, m2 |
| 65 | movhlps m6, m2 | 64 | movhlps m4, m2 |
| 66 | movaps [dstq ], m0 | 65 | blendps m2, m5, m1, 1100b |
| 67 | movaps [dstq+16], m4 | ||
| 68 | movaps [dstq+32], m6 | ||
| 69 | |||
| 70 | movaps m6, m5 | ||
| 71 | shufps m5, m1, q3210 | ||
| 72 | movlhps m1, m3 | 66 | movlhps m1, m3 |
| 73 | movhlps m6, m3 | 67 | movhlps m5, m3 |
| 68 | |||
| 69 | movaps [dstq ], m0 | ||
| 70 | movaps [dstq+16], m6 | ||
| 71 | movaps [dstq+32], m4 | ||
| 74 | movaps [dstq+48], m1 | 72 | movaps [dstq+48], m1 |
| 75 | movaps [dstq+64], m5 | 73 | movaps [dstq+64], m2 |
| 76 | movaps [dstq+80], m6 | 74 | movaps [dstq+80], m5 |
| 77 | %else ; mmx | 75 | %else ; mmx |
| 78 | SBUTTERFLY dq, 0, 1, 6 | 76 | SBUTTERFLY dq, 0, 1, 6 |
| 79 | SBUTTERFLY dq, 2, 3, 6 | 77 | SBUTTERFLY dq, 2, 3, 6 |
| @@ -100,5 +98,9 @@ cglobal conv_fltp_to_flt_6ch, 2,8,7, dst, src, src1, src2, src3, src4, src5, len · 20 unmodified lines | |||
| 100 | 98 | ||
| 101 | INIT_MMX mmx | 99 | INIT_MMX mmx |
| 102 | CONV_FLTP_TO_FLT_6CH | 100 | CONV_FLTP_TO_FLT_6CH |
| 103 | INIT_XMM sse | 101 | INIT_XMM sse4 |
| 102 | CONV_FLTP_TO_FLT_6CH | ||
| 103 | %if HAVE_AVX | ||
| 104 | INIT_XMM avx | ||
| 104 | CONV_FLTP_TO_FLT_6CH | 105 | CONV_FLTP_TO_FLT_6CH |
| 106 | %endif | ||
| @@ -22,8 +22,9 @@ · 21 unmodified lines | |||
| 22 | #include "libavutil/cpu.h" | 22 | #include "libavutil/cpu.h" |
| 23 | #include "libavresample/audio_convert.h" | 23 | #include "libavresample/audio_convert.h" |
| 24 | 24 | ||
| 25 | extern void ff_conv_fltp_to_flt_6ch_mmx(float *dst, float *const *src, int len); | 25 | extern void ff_conv_fltp_to_flt_6ch_mmx (float *dst, float *const *src, int len); |
| 26 | extern void ff_conv_fltp_to_flt_6ch_sse(float *dst, float *const *src, int len); | 26 | extern void ff_conv_fltp_to_flt_6ch_sse4(float *dst, float *const *src, int len); |
| 27 | extern void ff_conv_fltp_to_flt_6ch_avx (float *dst, float *const *src, int len); | ||
| 27 | 28 | ||
| 28 | av_cold void ff_audio_convert_init_x86(AudioConvert *ac) | 29 | av_cold void ff_audio_convert_init_x86(AudioConvert *ac) |
| 29 | { | 30 | { |
| @@ -34,9 +35,13 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac) · 4 unmodified lines | |||
| 34 | ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, | 35 | ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, |
| 35 | 6, 1, 4, "MMX", ff_conv_fltp_to_flt_6ch_mmx); | 36 | 6, 1, 4, "MMX", ff_conv_fltp_to_flt_6ch_mmx); |
| 36 | } | 37 | } |
| 37 | if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) { | 38 | if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) { |
| 38 | ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, | 39 | ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, |
| 39 | 6, 16, 4, "SSE", ff_conv_fltp_to_flt_6ch_sse); | 40 | 6, 16, 4, "SSE4", ff_conv_fltp_to_flt_6ch_sse4); |
| 41 | } | ||
| 42 | if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) { | ||
| 43 | ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, | ||
| 44 | 6, 16, 4, "AVX", ff_conv_fltp_to_flt_6ch_avx); | ||
| 40 | } | 45 | } |
| 41 | #endif | 46 | #endif |
| 42 | } | 47 | } |
| @@ -42,10 +42,9 @@ · 41 unmodified lines | |||
| 42 | %endmacro | 42 | %endmacro |
| 43 | 43 | ||
| 44 | %macro SBUTTERFLYPS 3 | 44 | %macro SBUTTERFLYPS 3 |
| 45 | movaps m%3, m%1 | 45 | unpcklps m%3, m%1, m%2 |
| 46 | unpcklps m%1, m%2 | 46 | unpckhps m%1, m%1, m%2 |
| 47 | unpckhps m%3, m%2 | 47 | SWAP %1, %3, %2 |
| 48 | SWAP %2, %3 | ||
| 49 | %endmacro | 48 | %endmacro |
| 50 | 49 | ||
| 51 | %macro TRANSPOSE4x4B 5 | 50 | %macro TRANSPOSE4x4B 5 |