* 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 | 38 | #if CONFIG_POSTPROC |
| 39 | 39 | #include "libpostproc/postprocess.h" |
| 40 | 40 | #endif |
| 41 | +#include "libavutil/avassert.h" | |
| 41 | 42 | #include "libavutil/avstring.h" |
| 42 | 43 | #include "libavutil/mathematics.h" |
| 43 | 44 | #include "libavutil/parseutils.h" |
| @@ -1075,7 +1076,7 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) · 1031 unmodified lines | ||
| 1075 | 1076 | case 's': type = AVMEDIA_TYPE_SUBTITLE; break; |
| 1076 | 1077 | case 'd': type = AVMEDIA_TYPE_DATA; break; |
| 1077 | 1078 | case 't': type = AVMEDIA_TYPE_ATTACHMENT; break; |
| 1078 | − default: abort(); // never reached, silence warning | |
| 1079 | + default: av_assert0(0); | |
| 1079 | 1080 | } |
| 1080 | 1081 | if (type != st->codec->codec_type) |
| 1081 | 1082 | return 0; |
| @@ -2662,7 +2662,7 @@ case $target_os in · 2661 unmodified lines | ||
| 2662 | 2662 | SHFLAGS='-shared -Wl,-h,$$(@F)' |
| 2663 | 2663 | enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS" |
| 2664 | 2664 | network_extralibs="-lsocket -lnsl" |
| 2665 | − add_cppflags -D__EXTENSIONS__ | |
| 2665 | + add_cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 | |
| 2666 | 2666 | # When using suncc to build, the Solaris linker will mark |
| 2667 | 2667 | # an executable with each instruction set encountered by |
| 2668 | 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 | 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 | 398 | int lim = rice->k ? (1 << (rice->k + 4)) : 0; |
| 399 | 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 | 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 | 411 | if (ctx->fileversion < 3990) { |
| 412 | 412 | int tmpk; |
| @@ -95,6 +95,7 @@ endfunc · 94 unmodified lines | ||
| 95 | 95 | .endm |
| 96 | 96 | |
| 97 | 97 | .macro pixels16_y2 rnd=1, avg=0 |
| 98 | + sub r3, r3, #2 | |
| 98 | 99 | vld1.64 {q0}, [r1], r2 |
| 99 | 100 | vld1.64 {q1}, [r1], r2 |
| 100 | 101 | 1: subs r3, r3, #2 |
| @@ -114,10 +115,25 @@ endfunc · 13 unmodified lines | ||
| 114 | 115 | vst1.64 {q2}, [r0,:128], r2 |
| 115 | 116 | vst1.64 {q3}, [r0,:128], r2 |
| 116 | 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 | 132 | bx lr |
| 118 | 133 | .endm |
| 119 | 134 | |
| 120 | 135 | .macro pixels16_xy2 rnd=1, avg=0 |
| 136 | + sub r3, r3, #2 | |
| 121 | 137 | vld1.64 {d0-d2}, [r1], r2 |
| 122 | 138 | vld1.64 {d4-d6}, [r1], r2 |
| 123 | 139 | .ifeq \rnd |
| @@ -173,6 +189,42 @@ endfunc · 49 unmodified lines | ||
| 173 | 189 | vaddl.u8 q11, d3, d5 |
| 174 | 190 | vst1.64 {q15}, [r0,:128], r2 |
| 175 | 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 | 228 | bx lr |
| 177 | 229 | .endm |
| 178 | 230 | |
| @@ -228,6 +280,7 @@ endfunc · 49 unmodified lines | ||
| 228 | 280 | .endm |
| 229 | 281 | |
| 230 | 282 | .macro pixels8_y2 rnd=1, avg=0 |
| 283 | + sub r3, r3, #2 | |
| 231 | 284 | vld1.64 {d0}, [r1], r2 |
| 232 | 285 | vld1.64 {d1}, [r1], r2 |
| 233 | 286 | 1: subs r3, r3, #2 |
| @@ -246,10 +299,24 @@ endfunc · 12 unmodified lines | ||
| 246 | 299 | vst1.64 {d4}, [r0,:64], r2 |
| 247 | 300 | vst1.64 {d5}, [r0,:64], r2 |
| 248 | 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 | 315 | bx lr |
| 250 | 316 | .endm |
| 251 | 317 | |
| 252 | 318 | .macro pixels8_xy2 rnd=1, avg=0 |
| 319 | + sub r3, r3, #2 | |
| 253 | 320 | vld1.64 {q0}, [r1], r2 |
| 254 | 321 | vld1.64 {q1}, [r1], r2 |
| 255 | 322 | .ifeq \rnd |
| @@ -291,6 +358,31 @@ endfunc · 35 unmodified lines | ||
| 291 | 358 | vaddl.u8 q9, d2, d6 |
| 292 | 359 | vst1.64 {d7}, [r0,:64], r2 |
| 293 | 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 | 386 | bx lr |
| 295 | 387 | .endm |
| 296 | 388 | |
| @@ -37,14 +37,14 @@ · 36 unmodified lines | ||
| 37 | 37 | #include "rectangle.h" |
| 38 | 38 | |
| 39 | 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 | |
| 43 | −#define MAX_PPS_COUNT 256 | |
| 42 | +#define MAX_SPS_COUNT 32 | |
| 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 | 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 | 61 | #define MAX_SLICES 16 |
| 62 | 62 | |
| 63 | 63 | #ifdef ALLOW_INTERLACE |
| 64 | −#define MB_MBAFF h->mb_mbaff | |
| 65 | −#define MB_FIELD h->mb_field_decoding_flag | |
| 64 | +#define MB_MBAFF h->mb_mbaff | |
| 65 | +#define MB_FIELD h->mb_field_decoding_flag | |
| 66 | 66 | #define FRAME_MBAFF h->mb_aff_frame |
| 67 | 67 | #define FIELD_PICTURE (s->picture_structure != PICT_FRAME) |
| 68 | 68 | #define LEFT_MBS 2 |
| 69 | −#define LTOP 0 | |
| 70 | −#define LBOT 1 | |
| 71 | −#define LEFT(i) (i) | |
| 69 | +#define LTOP 0 | |
| 70 | +#define LBOT 1 | |
| 71 | +#define LEFT(i) (i) | |
| 72 | 72 | #else |
| 73 | −#define MB_MBAFF 0 | |
| 74 | −#define MB_FIELD 0 | |
| 75 | −#define FRAME_MBAFF 0 | |
| 73 | +#define MB_MBAFF 0 | |
| 74 | +#define MB_FIELD 0 | |
| 75 | +#define FRAME_MBAFF 0 | |
| 76 | 76 | #define FIELD_PICTURE 0 |
| 77 | 77 | #undef IS_INTERLACED |
| 78 | 78 | #define IS_INTERLACED(mb_type) 0 |
| 79 | 79 | #define LEFT_MBS 1 |
| 80 | −#define LTOP 0 | |
| 81 | −#define LBOT 0 | |
| 82 | −#define LEFT(i) 0 | |
| 80 | +#define LTOP 0 | |
| 81 | +#define LBOT 0 | |
| 82 | +#define LEFT(i) 0 | |
| 83 | 83 | #endif |
| 84 | 84 | #define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF || FIELD_PICTURE) |
| 85 | 85 | |
| @@ -91,9 +91,9 @@ · 5 unmodified lines | ||
| 91 | 91 | #define CHROMA422 (h->sps.chroma_format_idc == 2) |
| 92 | 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 | 97 | #define MB_TYPE_8x8DCT 0x01000000 |
| 98 | 98 | #define IS_REF0(a) ((a) & MB_TYPE_REF0) |
| 99 | 99 | #define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT) |
| @@ -108,7 +108,7 @@ · 8 unmodified lines | ||
| 108 | 108 | |
| 109 | 109 | /* NAL unit types */ |
| 110 | 110 | enum { |
| 111 | − NAL_SLICE=1, | |
| 111 | + NAL_SLICE = 1, | |
| 112 | 112 | NAL_DPA, |
| 113 | 113 | NAL_DPB, |
| 114 | 114 | NAL_DPC, |
| @@ -121,17 +121,17 @@ enum { · 6 unmodified lines | ||
| 121 | 121 | NAL_END_STREAM, |
| 122 | 122 | NAL_FILLER_DATA, |
| 123 | 123 | NAL_SPS_EXT, |
| 124 | − NAL_AUXILIARY_SLICE=19 | |
| 124 | + NAL_AUXILIARY_SLICE = 19 | |
| 125 | 125 | }; |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * SEI message types |
| 129 | 129 | */ |
| 130 | 130 | typedef enum { |
| 131 | − SEI_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1) | |
| 132 | − SEI_TYPE_PIC_TIMING = 1, ///< picture timing | |
| 133 | − SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data | |
| 134 | − SEI_TYPE_RECOVERY_POINT = 6 ///< recovery point (frame # to decoder sync) | |
| 131 | + SEI_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1) | |
| 132 | + SEI_TYPE_PIC_TIMING = 1, ///< picture timing | |
| 133 | + SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data | |
| 134 | + SEI_TYPE_RECOVERY_POINT = 6 ///< recovery point (frame # to decoder sync) | |
| 135 | 135 | } SEI_Type; |
| 136 | 136 | |
| 137 | 137 | /** |
| @@ -152,8 +152,7 @@ typedef enum { · 14 unmodified lines | ||
| 152 | 152 | /** |
| 153 | 153 | * Sequence parameter set |
| 154 | 154 | */ |
| 155 | −typedef struct SPS{ | |
| 156 | − | |
| 155 | +typedef struct SPS { | |
| 157 | 156 | int profile_idc; |
| 158 | 157 | int level_idc; |
| 159 | 158 | int chroma_format_idc; |
| @@ -170,9 +169,9 @@ typedef struct SPS{ · 10 unmodified lines | ||
| 170 | 169 | int mb_width; ///< pic_width_in_mbs_minus1 + 1 |
| 171 | 170 | int mb_height; ///< pic_height_in_map_units_minus1 + 1 |
| 172 | 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 | 173 | int direct_8x8_inference_flag; |
| 175 | − int crop; ///< frame_cropping_flag | |
| 174 | + int crop; ///< frame_cropping_flag | |
| 176 | 175 | unsigned int crop_left; ///< frame_cropping_rect_left_offset |
| 177 | 176 | unsigned int crop_right; ///< frame_cropping_rect_right_offset |
| 178 | 177 | unsigned int crop_top; ///< frame_cropping_rect_top_offset |
| @@ -189,7 +188,7 @@ typedef struct SPS{ · 10 unmodified lines | ||
| 189 | 188 | uint32_t num_units_in_tick; |
| 190 | 189 | uint32_t time_scale; |
| 191 | 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 | 192 | int bitstream_restriction_flag; |
| 194 | 193 | int num_reorder_frames; |
| 195 | 194 | int scaling_matrix_present; |
| @@ -199,20 +198,20 @@ typedef struct SPS{ · 3 unmodified lines | ||
| 199 | 198 | int vcl_hrd_parameters_present_flag; |
| 200 | 199 | int pic_struct_present_flag; |
| 201 | 200 | int time_offset_length; |
| 202 | − int cpb_cnt; ///< See H.264 E.1.2 | |
| 203 | − 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 | |
| 205 | − int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1 | |
| 206 | − int bit_depth_luma; ///< bit_depth_luma_minus8 + 8 | |
| 207 | − int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8 | |
| 208 | − int residual_color_transform_flag; ///< residual_colour_transform_flag | |
| 209 | − int constraint_set_flags; ///< constraint_set[0-3]_flag | |
| 210 | −}SPS; | |
| 201 | + int cpb_cnt; ///< See H.264 E.1.2 | |
| 202 | + int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 + 1 | |
| 203 | + int cpb_removal_delay_length; ///< cpb_removal_delay_length_minus1 + 1 | |
| 204 | + int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1 | |
| 205 | + int bit_depth_luma; ///< bit_depth_luma_minus8 + 8 | |
| 206 | + int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8 | |
| 207 | + int residual_color_transform_flag; ///< residual_colour_transform_flag | |
| 208 | + int constraint_set_flags; ///< constraint_set[0-3]_flag | |
| 209 | +} SPS; | |
| 211 | 210 | |
| 212 | 211 | /** |
| 213 | 212 | * Picture parameter set |
| 214 | 213 | */ |
| 215 | −typedef struct PPS{ | |
| 214 | +typedef struct PPS { | |
| 216 | 215 | unsigned int sps_id; |
| 217 | 216 | int cabac; ///< entropy_coding_mode_flag |
| 218 | 217 | int pic_order_present; ///< pic_order_present_flag |
| @@ -225,20 +224,20 @@ typedef struct PPS{ · 6 unmodified lines | ||
| 225 | 224 | int init_qs; ///< pic_init_qs_minus26 + 26 |
| 226 | 225 | int chroma_qp_index_offset[2]; |
| 227 | 226 | int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag |
| 228 | − int constrained_intra_pred; ///< constrained_intra_pred_flag | |
| 229 | − int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag | |
| 230 | − int transform_8x8_mode; ///< transform_8x8_mode_flag | |
| 227 | + int constrained_intra_pred; ///< constrained_intra_pred_flag | |
| 228 | + int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag | |
| 229 | + int transform_8x8_mode; ///< transform_8x8_mode_flag | |
| 231 | 230 | uint8_t scaling_matrix4[6][16]; |
| 232 | 231 | uint8_t scaling_matrix8[6][64]; |
| 233 | 232 | uint8_t chroma_qp_table[2][QP_MAX_NUM+1]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table |
| 234 | 233 | int chroma_qp_diff; |
| 235 | −}PPS; | |
| 234 | +} PPS; | |
| 236 | 235 | |
| 237 | 236 | /** |
| 238 | 237 | * Memory management control operation opcode. |
| 239 | 238 | */ |
| 240 | −typedef enum MMCOOpcode{ | |
| 241 | − MMCO_END=0, | |
| 239 | +typedef enum MMCOOpcode { | |
| 240 | + MMCO_END = 0, | |
| 242 | 241 | MMCO_SHORT2UNUSED, |
| 243 | 242 | MMCO_LONG2UNUSED, |
| 244 | 243 | MMCO_SHORT2LONG, |
| @@ -250,7 +249,7 @@ typedef enum MMCOOpcode{ · 5 unmodified lines | ||
| 250 | 249 | /** |
| 251 | 250 | * Memory management control operation. |
| 252 | 251 | */ |
| 253 | −typedef struct MMCO{ | |
| 252 | +typedef struct MMCO { | |
| 254 | 253 | MMCOOpcode opcode; |
| 255 | 254 | int short_pic_num; ///< pic_num without wrapping (pic_num & max_pic_num) |
| 256 | 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 | 259 | * H264Context |
| 261 | 260 | */ |
| 262 | −typedef struct H264Context{ | |
| 261 | +typedef struct H264Context { | |
| 263 | 262 | MpegEncContext s; |
| 264 | 263 | H264DSPContext h264dsp; |
| 265 | 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 | 267 | int qp_thresh; ///< QP threshold to skip loopfilter |
| 269 | 268 | |
| 270 | 269 | int prev_mb_skipped; |
| 271 | 270 | int next_mb_skipped; |
| 272 | 271 | |
| 273 | − //prediction stuff | |
| 272 | + // prediction stuff | |
| 274 | 273 | int chroma_pred_mode; |
| 275 | 274 | int intra16x16_pred_mode; |
| 276 | 275 | |
| @@ -284,32 +283,32 @@ typedef struct H264Context{ · 7 unmodified lines | ||
| 284 | 283 | int topright_type; |
| 285 | 284 | int left_type[LEFT_MBS]; |
| 286 | 285 | |
| 287 | − const uint8_t * left_block; | |
| 286 | + const uint8_t *left_block; | |
| 288 | 287 | int topleft_partition; |
| 289 | 288 | |
| 290 | − int8_t intra4x4_pred_mode_cache[5*8]; | |
| 291 | − int8_t (*intra4x4_pred_mode); | |
| 289 | + int8_t intra4x4_pred_mode_cache[5 * 8]; | |
| 290 | + int8_t(*intra4x4_pred_mode); | |
| 292 | 291 | H264PredContext hpc; |
| 293 | 292 | unsigned int topleft_samples_available; |
| 294 | 293 | unsigned int top_samples_available; |
| 295 | 294 | unsigned int topright_samples_available; |
| 296 | 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 | 299 | * non zero coeff count cache. |
| 301 | 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 | 304 | uint8_t (*non_zero_count)[48]; |
| 306 | 305 | |
| 307 | 306 | /** |
| 308 | 307 | * Motion vector cache. |
| 309 | 308 | */ |
| 310 | − DECLARE_ALIGNED(16, int16_t, mv_cache)[2][5*8][2]; | |
| 311 | − DECLARE_ALIGNED(8, int8_t, ref_cache)[2][5*8]; | |
| 312 | −#define LIST_NOT_USED -1 //FIXME rename? | |
| 309 | + DECLARE_ALIGNED(16, int16_t, mv_cache)[2][5 * 8][2]; | |
| 310 | + DECLARE_ALIGNED(8, int8_t, ref_cache)[2][5 * 8]; | |
| 311 | +#define LIST_NOT_USED -1 // FIXME rename? | |
| 313 | 312 | #define PART_NOT_AVAILABLE -2 |
| 314 | 313 | |
| 315 | 314 | /** |
| @@ -321,13 +320,13 @@ typedef struct H264Context{ · 5 unmodified lines | ||
| 321 | 320 | * block_offset[ 0..23] for frame macroblocks |
| 322 | 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 | 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 | 330 | int mb_uvlinesize; |
| 332 | 331 | |
| 333 | 332 | int emu_edge_width; |
| @@ -338,32 +337,32 @@ typedef struct H264Context{ · 4 unmodified lines | ||
| 338 | 337 | /** |
| 339 | 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? | |
| 344 | − uint32_t dequant8_buffer[6][QP_MAX_NUM+1][64]; | |
| 345 | − uint32_t (*dequant4_coeff[6])[16]; | |
| 346 | − uint32_t (*dequant8_coeff[6])[64]; | |
| 342 | + uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16]; // FIXME should these be moved down? | |
| 343 | + uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64]; | |
| 344 | + uint32_t(*dequant4_coeff[6])[16]; | |
| 345 | + uint32_t(*dequant8_coeff[6])[64]; | |
| 347 | 346 | |
| 348 | 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 | 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 | 351 | int slice_type_fixed; |
| 353 | 352 | |
| 354 | − //interlacing specific flags | |
| 353 | + // interlacing specific flags | |
| 355 | 354 | int mb_aff_frame; |
| 356 | 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 | 358 | DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4]; |
| 360 | 359 | |
| 361 | − //Weighted pred stuff | |
| 360 | + // Weighted pred stuff | |
| 362 | 361 | int use_weight; |
| 363 | 362 | int use_weight_chroma; |
| 364 | 363 | int luma_log2_weight_denom; |
| 365 | 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 | 366 | int luma_weight[48][2][2]; |
| 368 | 367 | int chroma_weight[48][2][2][2]; |
| 369 | 368 | int implicit_weight[48][48][2]; |
| @@ -373,48 +372,48 @@ typedef struct H264Context{ · 3 unmodified lines | ||
| 373 | 372 | int col_fieldoff; |
| 374 | 373 | int dist_scale_factor[16]; |
| 375 | 374 | int dist_scale_factor_field[2][32]; |
| 376 | − int map_col_to_list0[2][16+32]; | |
| 377 | − int map_col_to_list0_field[2][2][16+32]; | |
| 375 | + int map_col_to_list0[2][16 + 32]; | |
| 376 | + int map_col_to_list0_field[2][2][16 + 32]; | |
| 378 | 377 | |
| 379 | 378 | /** |
| 380 | 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 | |
| 383 | − unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode | |
| 381 | + unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode | |
| 384 | 382 | unsigned int list_count; |
| 385 | − Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs. | |
| 386 | − Reordered version of default_ref_list | |
| 387 | − according to picture reordering in slice header */ | |
| 388 | − int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1 | |
| 383 | + uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type | |
| 384 | + Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs. | |
| 385 | + * Reordered version of default_ref_list | |
| 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 | 390 | GetBitContext intra_gb; |
| 392 | 391 | GetBitContext inter_gb; |
| 393 | 392 | GetBitContext *intra_gb_ptr; |
| 394 | 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. | |
| 397 | − 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 | |
| 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. | |
| 396 | + DECLARE_ALIGNED(16, DCTELEM, mb_luma_dc)[3][16 * 2]; | |
| 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 | 400 | * Cabac |
| 402 | 401 | */ |
| 403 | 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 */ | |
| 407 | − uint16_t *cbp_table; | |
| 405 | + /* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0, 1, 2), 0x0? luma_cbp */ | |
| 406 | + uint16_t *cbp_table; | |
| 408 | 407 | int cbp; |
| 409 | 408 | int top_cbp; |
| 410 | 409 | int left_cbp; |
| 411 | 410 | /* chroma_pred_mode for i4x4 or i16x16, else 0 */ |
| 412 | − uint8_t *chroma_pred_mode_table; | |
| 413 | − int last_qscale_diff; | |
| 414 | − uint8_t (*mvd_table[2])[2]; | |
| 415 | − DECLARE_ALIGNED(16, uint8_t, mvd_cache)[2][5*8][2]; | |
| 416 | − uint8_t *direct_table; | |
| 417 | − uint8_t direct_cache[5*8]; | |
| 411 | + uint8_t *chroma_pred_mode_table; | |
| 412 | + int last_qscale_diff; | |
| 413 | + uint8_t (*mvd_table[2])[2]; | |
| 414 | + DECLARE_ALIGNED(16, uint8_t, mvd_cache)[2][5 * 8][2]; | |
| 415 | + uint8_t *direct_table; | |
| 416 | + uint8_t direct_cache[5 * 8]; | |
| 418 | 417 | |
| 419 | 418 | uint8_t zigzag_scan[16]; |
| 420 | 419 | uint8_t zigzag_scan8x8[64]; |
| @@ -435,13 +434,13 @@ typedef struct H264Context{ · 14 unmodified lines | ||
| 435 | 434 | |
| 436 | 435 | int is_complex; |
| 437 | 436 | |
| 438 | − //deblock | |
| 439 | − int deblocking_filter; ///< disable_deblocking_filter_idc with 1<->0 | |
| 437 | + // deblock | |
| 438 | + int deblocking_filter; ///< disable_deblocking_filter_idc with 1 <-> 0 | |
| 440 | 439 | int slice_alpha_c0_offset; |
| 441 | 440 | int slice_beta_offset; |
| 442 | 441 | |
| 443 | −//============================================================= | |
| 444 | − //Things below are not used in the MB or more inner code | |
| 442 | + // ============================================================= | |
| 443 | + // Things below are not used in the MB or more inner code | |
| 445 | 444 | |
| 446 | 445 | int nal_ref_idc; |
| 447 | 446 | int nal_unit_type; |
| @@ -451,37 +450,36 @@ typedef struct H264Context{ · 3 unmodified lines | ||
| 451 | 450 | /** |
| 452 | 451 | * Used to parse AVC variant of h264 |
| 453 | 452 | */ |
| 454 | − 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) | |
| 456 | − int got_first; ///< this flag is != 0 if we've parsed a frame | |
| 453 | + int is_avc; ///< this flag is != 0 if codec is avc1 | |
| 454 | + int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4) | |
| 455 | + int got_first; ///< this flag is != 0 if we've parsed a frame | |
| 457 | 456 | |
| 458 | 457 | SPS *sps_buffers[MAX_SPS_COUNT]; |
| 459 | 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 | 462 | uint16_t *slice_table_base; |
| 464 | 463 | |
| 465 | − | |
| 466 | − //POC stuff | |
| 464 | + // POC stuff | |
| 467 | 465 | int poc_lsb; |
| 468 | 466 | int poc_msb; |
| 469 | 467 | int delta_poc_bottom; |
| 470 | 468 | int delta_poc[2]; |
| 471 | 469 | int frame_num; |
| 472 | − 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 | |
| 474 | − int frame_num_offset; ///< for POC type 2 | |
| 475 | − 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 | |
| 470 | + int prev_poc_msb; ///< poc_msb 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 | |
| 472 | + int frame_num_offset; ///< for POC type 2 | |
| 473 | + int prev_frame_num_offset; ///< for POC type 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 | 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 | 484 | int max_pic_num; |
| 487 | 485 | |
| @@ -490,7 +488,7 @@ typedef struct H264Context{ · 2 unmodified lines | ||
| 490 | 488 | Picture *short_ref[32]; |
| 491 | 489 | Picture *long_ref[32]; |
| 492 | 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 | 492 | int last_pocs[MAX_DELAYED_PIC_COUNT]; |
| 495 | 493 | Picture *next_output_pic; |
| 496 | 494 | int outputed_poc; |
| @@ -503,10 +501,10 @@ typedef struct H264Context{ · 6 unmodified lines | ||
| 503 | 501 | int mmco_index; |
| 504 | 502 | int mmco_reset; |
| 505 | 503 | |
| 506 | − int long_ref_count; ///< number of actual long term references | |
| 507 | − int short_ref_count; ///< number of actual short term references | |
| 504 | + int long_ref_count; ///< number of actual long 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 | 510 | * @name Members for slice based multithreading |
| @@ -582,12 +580,12 @@ typedef struct H264Context{ · 69 unmodified lines | ||
| 582 | 580 | */ |
| 583 | 581 | int recovery_frame; |
| 584 | 582 | |
| 585 | − 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 | |
| 583 | + int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag | |
| 584 | + int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag | |
| 587 | 585 | |
| 588 | 586 | // Timestamp stuff |
| 589 | − int sei_buffering_period_present; ///< Buffering period SEI flag | |
| 590 | − int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs | |
| 587 | + int sei_buffering_period_present; ///< Buffering period SEI flag | |
| 588 | + int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs | |
| 591 | 589 | |
| 592 | 590 | int cur_chroma_format_idc; |
| 593 | 591 | |
| @@ -598,10 +596,9 @@ typedef struct H264Context{ · 4 unmodified lines | ||
| 598 | 596 | uint8_t parse_history[4]; |
| 599 | 597 | int parse_history_count; |
| 600 | 598 | int parse_last_mb; |
| 601 | −}H264Context; | |
| 602 | − | |
| 599 | +} H264Context; | |
| 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 | 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 | 625 | * Decode a network abstraction layer unit. |
| 629 | 626 | * @param consumed is the number of bytes used as input |
| 630 | 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 | 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 | 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 | 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 | 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 | 680 | int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma); |
| 677 | 681 | |
| 678 | 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 | 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 | 692 | int ff_h264_decode_mb_cavlc(H264Context *h); |
| 689 | 693 | |
| 690 | 694 | /** |
| 691 | 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 | 698 | int ff_h264_decode_mb_cabac(H264Context *h); |
| 695 | 699 | |
| 696 | 700 | void ff_h264_init_cabac_states(H264Context *h); |
| 697 | 701 | |
| 698 | −void ff_h264_direct_dist_scale_factor(H264Context * const h); | |
| 699 | −void ff_h264_direct_ref_list_init(H264Context * const h); | |
| 700 | −void ff_h264_pred_direct_motion(H264Context * const h, int *mb_type); | |
| 702 | +void ff_h264_direct_dist_scale_factor(H264Context *const h); | |
| 703 | +void ff_h264_direct_ref_list_init(H264Context *const h); | |
| 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); | |
| 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); | |
| 706 | +void ff_h264_filter_mb_fast(H264Context *h, int mb_x, int mb_y, | |
| 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 | 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 | 718 | void ff_h264_reset_sei(H264Context *h); |
| 711 | 719 | |
| 712 | − | |
| 713 | 720 | /* |
| 714 | −o-o o-o | |
| 715 | − / / / | |
| 716 | −o-o o-o | |
| 717 | − ,---' | |
| 718 | −o-o o-o | |
| 719 | − / / / | |
| 720 | −o-o o-o | |
| 721 | −*/ | |
| 721 | + * o-o o-o | |
| 722 | + * / / / | |
| 723 | + * o-o o-o | |
| 724 | + * ,---' | |
| 725 | + * o-o o-o | |
| 726 | + * / / / | |
| 727 | + * o-o o-o | |
| 728 | + */ | |
| 722 | 729 | |
| 723 | 730 | /* Scan8 organization: |
| 724 | 731 | * 0 1 2 3 4 5 6 7 |
| @@ -743,156 +750,173 @@ o-o o-o · 18 unmodified lines | ||
| 743 | 750 | #define LUMA_DC_BLOCK_INDEX 48 |
| 744 | 751 | #define CHROMA_DC_BLOCK_INDEX 49 |
| 745 | 752 | |
| 746 | −//This table must be here because scan8[constant] must be known at compiletime | |
| 747 | −static const uint8_t scan8[16*3 + 3]={ | |
| 748 | − 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, | |
| 750 | − 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, | |
| 752 | − 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, | |
| 754 | − 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, | |
| 756 | − 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, | |
| 758 | − 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, | |
| 760 | − 0+ 0*8, 0+ 5*8, 0+10*8 | |
| 753 | +// This table must be here because scan8[constant] must be known at compiletime | |
| 754 | +static const uint8_t scan8[16 * 3 + 3] = { | |
| 755 | + 4 + 1 * 8, 5 + 1 * 8, 4 + 2 * 8, 5 + 2 * 8, | |
| 756 | + 6 + 1 * 8, 7 + 1 * 8, 6 + 2 * 8, 7 + 2 * 8, | |
| 757 | + 4 + 3 * 8, 5 + 3 * 8, 4 + 4 * 8, 5 + 4 * 8, | |
| 758 | + 6 + 3 * 8, 7 + 3 * 8, 6 + 4 * 8, 7 + 4 * 8, | |
| 759 | + 4 + 6 * 8, 5 + 6 * 8, 4 + 7 * 8, 5 + 7 * 8, | |
| 760 | + 6 + 6 * 8, 7 + 6 * 8, 6 + 7 * 8, 7 + 7 * 8, | |
| 761 | + 4 + 8 * 8, 5 + 8 * 8, 4 + 9 * 8, 5 + 9 * 8, | |
| 762 | + 6 + 8 * 8, 7 + 8 * 8, 6 + 9 * 8, 7 + 9 * 8, | |
| 763 | + 4 + 11 * 8, 5 + 11 * 8, 4 + 12 * 8, 5 + 12 * 8, | |
| 764 | + 6 + 11 * 8, 7 + 11 * 8, 6 + 12 * 8, 7 + 12 * 8, | |
| 765 | + 4 + 13 * 8, 5 + 13 * 8, 4 + 14 * 8, 5 + 14 * 8, | |
| 766 | + 6 + 13 * 8, 7 + 13 * 8, 6 + 14 * 8, 7 + 14 * 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 | 772 | #if HAVE_BIGENDIAN |
| 765 | − return (b&0xFFFF) + (a<<16); | |
| 773 | + return (b & 0xFFFF) + (a << 16); | |
| 766 | 774 | #else |
| 767 | − return (a&0xFFFF) + (b<<16); | |
| 775 | + return (a & 0xFFFF) + (b << 16); | |
| 768 | 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 | 781 | #if HAVE_BIGENDIAN |
| 773 | − return (b&0xFF) + (a<<8); | |
| 782 | + return (b & 0xFF) + (a << 8); | |
| 774 | 783 | #else |
| 775 | − return (a&0xFF) + (b<<8); | |
| 784 | + return (a & 0xFF) + (b << 8); | |
| 776 | 785 | #endif |
| 777 | 786 | } |
| 778 | 787 | |
| 779 | 788 | /** |
| 780 | 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 | 793 | return h->pps.chroma_qp_table[t][qscale]; |
| 784 | 794 | } |
| 785 | 795 | |
| 786 | 796 | /** |
| 787 | 797 | * Get the predicted intra4x4 prediction mode. |
| 788 | 798 | */ |
| 789 | −static av_always_inline int pred_intra_mode(H264Context *h, int n){ | |
| 790 | − const int index8= scan8[n]; | |
| 791 | − const int left= h->intra4x4_pred_mode_cache[index8 - 1]; | |
| 792 | − const int top = h->intra4x4_pred_mode_cache[index8 - 8]; | |
| 793 | − const int min= FFMIN(left, top); | |
| 799 | +static av_always_inline int pred_intra_mode(H264Context *h, int n) | |
| 800 | +{ | |
| 801 | + const int index8 = scan8[n]; | |
| 802 | + const int left = h->intra4x4_pred_mode_cache[index8 - 1]; | |
| 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; | |
| 798 | − else return min; | |
| 808 | + if (min < 0) | |
| 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){ | |
| 802 | − int8_t *i4x4= h->intra4x4_pred_mode + h->mb2br_xy[h->mb_xy]; | |
| 803 | − int8_t *i4x4_cache= h->intra4x4_pred_mode_cache; | |
| 814 | +static av_always_inline void write_back_intra_pred_mode(H264Context *h) | |
| 815 | +{ | |
| 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); | |
| 806 | − i4x4[4]= i4x4_cache[7+8*3]; | |
| 807 | − i4x4[5]= i4x4_cache[7+8*2]; | |
| 808 | − i4x4[6]= i4x4_cache[7+8*1]; | |
| 819 | + AV_COPY32(i4x4, i4x4_cache + 4 + 8 * 4); | |
| 820 | + i4x4[4] = i4x4_cache[7 + 8 * 3]; | |
| 821 | + i4x4[5] = i4x4_cache[7 + 8 * 2]; | |
| 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){ | |
| 812 | − const int mb_xy= h->mb_xy; | |
| 813 | − uint8_t *nnz = h->non_zero_count[mb_xy]; | |
| 825 | +static av_always_inline void write_back_non_zero_count(H264Context *h) | |
| 826 | +{ | |
| 827 | + const int mb_xy = h->mb_xy; | |
| 828 | + uint8_t *nnz = h->non_zero_count[mb_xy]; | |
| 814 | 829 | uint8_t *nnz_cache = h->non_zero_count_cache; |
| 815 | 830 | |
| 816 | − AV_COPY32(&nnz[ 0], &nnz_cache[4+8* 1]); | |
| 817 | − AV_COPY32(&nnz[ 4], &nnz_cache[4+8* 2]); | |
| 818 | − AV_COPY32(&nnz[ 8], &nnz_cache[4+8* 3]); | |
| 819 | − AV_COPY32(&nnz[12], &nnz_cache[4+8* 4]); | |
| 820 | − AV_COPY32(&nnz[16], &nnz_cache[4+8* 6]); | |
| 821 | − AV_COPY32(&nnz[20], &nnz_cache[4+8* 7]); | |
| 822 | − AV_COPY32(&nnz[32], &nnz_cache[4+8*11]); | |
| 823 | − AV_COPY32(&nnz[36], &nnz_cache[4+8*12]); | |
| 824 | − | |
| 825 | − if(!h->s.chroma_y_shift){ | |
| 826 | − AV_COPY32(&nnz[24], &nnz_cache[4+8* 8]); | |
| 827 | − AV_COPY32(&nnz[28], &nnz_cache[4+8* 9]); | |
| 828 | − AV_COPY32(&nnz[40], &nnz_cache[4+8*13]); | |
| 829 | − AV_COPY32(&nnz[44], &nnz_cache[4+8*14]); | |
| 831 | + AV_COPY32(&nnz[ 0], &nnz_cache[4 + 8 * 1]); | |
| 832 | + AV_COPY32(&nnz[ 4], &nnz_cache[4 + 8 * 2]); | |
| 833 | + AV_COPY32(&nnz[ 8], &nnz_cache[4 + 8 * 3]); | |
| 834 | + AV_COPY32(&nnz[12], &nnz_cache[4 + 8 * 4]); | |
| 835 | + AV_COPY32(&nnz[16], &nnz_cache[4 + 8 * 6]); | |
| 836 | + AV_COPY32(&nnz[20], &nnz_cache[4 + 8 * 7]); | |
| 837 | + AV_COPY32(&nnz[32], &nnz_cache[4 + 8 * 11]); | |
| 838 | + AV_COPY32(&nnz[36], &nnz_cache[4 + 8 * 12]); | |
| 839 | + | |
| 840 | + if (!h->s.chroma_y_shift) { | |
| 841 | + AV_COPY32(&nnz[24], &nnz_cache[4 + 8 * 8]); | |
| 842 | + AV_COPY32(&nnz[28], &nnz_cache[4 + 8 * 9]); | |
| 843 | + AV_COPY32(&nnz[40], &nnz_cache[4 + 8 * 13]); | |
| 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, | |
| 834 | − int b_xy, int b8_xy, int mb_type, int list ) | |
| 848 | +static av_always_inline void write_back_motion_list(H264Context *h, | |
| 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]; | |
| 837 | − int16_t (*mv_src)[2] = &h->mv_cache[list][scan8[0]]; | |
| 838 | − AV_COPY128(mv_dst + 0*b_stride, mv_src + 8*0); | |
| 839 | − AV_COPY128(mv_dst + 1*b_stride, mv_src + 8*1); | |
| 840 | − AV_COPY128(mv_dst + 2*b_stride, mv_src + 8*2); | |
| 841 | − AV_COPY128(mv_dst + 3*b_stride, mv_src + 8*3); | |
| 842 | − if( CABAC ) { | |
| 843 | − uint8_t (*mvd_dst)[2] = &h->mvd_table[list][FMO ? 8*h->mb_xy : h->mb2br_xy[h->mb_xy]]; | |
| 844 | − uint8_t (*mvd_src)[2] = &h->mvd_cache[list][scan8[0]]; | |
| 845 | − if(IS_SKIP(mb_type)) | |
| 854 | + int16_t(*mv_dst)[2] = &s->current_picture.f.motion_val[list][b_xy]; | |
| 855 | + int16_t(*mv_src)[2] = &h->mv_cache[list][scan8[0]]; | |
| 856 | + AV_COPY128(mv_dst + 0 * b_stride, mv_src + 8 * 0); | |
| 857 | + AV_COPY128(mv_dst + 1 * b_stride, mv_src + 8 * 1); | |
| 858 | + AV_COPY128(mv_dst + 2 * b_stride, mv_src + 8 * 2); | |
| 859 | + AV_COPY128(mv_dst + 3 * b_stride, mv_src + 8 * 3); | |
| 860 | + if (CABAC) { | |
| 861 | + uint8_t (*mvd_dst)[2] = &h->mvd_table[list][FMO ? 8 * h->mb_xy | |
| 862 | + : h->mb2br_xy[h->mb_xy]]; | |
| 863 | + uint8_t(*mvd_src)[2] = &h->mvd_cache[list][scan8[0]]; | |
| 864 | + if (IS_SKIP(mb_type)) { | |
| 846 | 865 | AV_ZERO128(mvd_dst); |
| 847 | − else{ | |
| 848 | − AV_COPY64(mvd_dst, mvd_src + 8*3); | |
| 849 | − AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8*0); | |
| 850 | − AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8*1); | |
| 851 | − AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8*2); | |
| 866 | + } else { | |
| 867 | + AV_COPY64(mvd_dst, mvd_src + 8 * 3); | |
| 868 | + AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8 * 0); | |
| 869 | + AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8 * 1); | |
| 870 | + AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8 * 2); | |
| 852 | 871 | } |
| 853 | 872 | } |
| 854 | 873 | |
| 855 | 874 | { |
| 856 | 875 | int8_t *ref_index = &s->current_picture.f.ref_index[list][b8_xy]; |
| 857 | 876 | int8_t *ref_cache = h->ref_cache[list]; |
| 858 | − ref_index[0+0*2]= ref_cache[scan8[0]]; | |
| 859 | − ref_index[1+0*2]= ref_cache[scan8[4]]; | |
| 860 | − ref_index[0+1*2]= ref_cache[scan8[8]]; | |
| 861 | − ref_index[1+1*2]= ref_cache[scan8[12]]; | |
| 877 | + ref_index[0 + 0 * 2] = ref_cache[scan8[0]]; | |
| 878 | + ref_index[1 + 0 * 2] = ref_cache[scan8[4]]; | |
| 879 | + ref_index[0 + 1 * 2] = ref_cache[scan8[8]]; | |
| 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){ | |
| 866 | − MpegEncContext * const s = &h->s; | |
| 867 | − const int b_stride = h->b_stride; | |
| 868 | − const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride; //try mb2b(8)_xy | |
| 869 | − const int b8_xy= 4*h->mb_xy; | |
| 884 | +static av_always_inline void write_back_motion(H264Context *h, int mb_type) | |
| 885 | +{ | |
| 886 | + MpegEncContext *const s = &h->s; | |
| 887 | + const int b_stride = h->b_stride; | |
| 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 | 892 | write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0); |
| 873 | − }else{ | |
| 893 | + } else { | |
| 874 | 894 | fill_rectangle(&s->current_picture.f.ref_index[0][b8_xy], |
| 875 | 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 | 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){ | |
| 882 | − if(IS_8X8(mb_type)){ | |
| 883 | − uint8_t *direct_table = &h->direct_table[4*h->mb_xy]; | |
| 884 | − direct_table[1] = h->sub_mb_type[1]>>1; | |
| 885 | − direct_table[2] = h->sub_mb_type[2]>>1; | |
| 886 | − direct_table[3] = h->sub_mb_type[3]>>1; | |
| 900 | + if (h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC) { | |
| 901 | + if (IS_8X8(mb_type)) { | |
| 902 | + uint8_t *direct_table = &h->direct_table[4 * h->mb_xy]; | |
| 903 | + direct_table[1] = h->sub_mb_type[1] >> 1; | |
| 904 | + direct_table[2] = h->sub_mb_type[2] >> 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){ | |
| 892 | − if(h->sps.direct_8x8_inference_flag) | |
| 893 | − return !(AV_RN64A(h->sub_mb_type) & ((MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8 )*0x0001000100010001ULL)); | |
| 910 | +static av_always_inline int get_dct8x8_allowed(H264Context *h) | |
| 911 | +{ | |
| 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 | 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 | 922 | #endif /* AVCODEC_H264_H */ |
| @@ -35,53 +35,53 @@ · 34 unmodified lines | ||
| 35 | 35 | //#undef NDEBUG |
| 36 | 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){ | |
| 39 | − const int topright_ref= h->ref_cache[list][ i - 8 + part_width ]; | |
| 40 | − MpegEncContext *s = &h->s; | |
| 38 | +static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, | |
| 39 | + int i, int list, int part_width) | |
| 40 | +{ | |
| 41 | + const int topright_ref = h->ref_cache[list][i - 8 + part_width]; | |
| 42 | + MpegEncContext *s = &h->s; | |
| 41 | 43 | |
| 42 | 44 | /* there is no consistent mapping of mvs to neighboring locations that will |
| 43 | 45 | * make mbaff happy, so we can't move all this logic to fill_caches */ |
| 44 | − if(FRAME_MBAFF){ | |
| 45 | − | |
| 46 | −#define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4)\ | |
| 47 | − const int xy = XY, y4 = Y4;\ | |
| 48 | − const int mb_type = mb_types[xy+(y4>>2)*s->mb_stride];\ | |
| 49 | − if(!USES_LIST(mb_type,list))\ | |
| 50 | − return LIST_NOT_USED;\ | |
| 51 | − mv = s->current_picture_ptr->f.motion_val[list][h->mb2b_xy[xy] + 3 + y4*h->b_stride];\ | |
| 52 | − h->mv_cache[list][scan8[0]-2][0] = mv[0];\ | |
| 53 | − h->mv_cache[list][scan8[0]-2][1] = mv[1] MV_OP;\ | |
| 54 | − return s->current_picture_ptr->f.ref_index[list][4*xy + 1 + (y4 & ~1)] REF_OP; | |
| 55 | − | |
| 56 | − if(topright_ref == PART_NOT_AVAILABLE | |
| 57 | − && i >= scan8[0]+8 && (i&7)==4 | |
| 58 | − && h->ref_cache[list][scan8[0]-1] != PART_NOT_AVAILABLE){ | |
| 46 | + if (FRAME_MBAFF) { | |
| 47 | +#define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4) \ | |
| 48 | + const int xy = XY, y4 = Y4; \ | |
| 49 | + const int mb_type = mb_types[xy + (y4 >> 2) * s->mb_stride]; \ | |
| 50 | + if (!USES_LIST(mb_type, list)) \ | |
| 51 | + return LIST_NOT_USED; \ | |
| 52 | + 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]; \ | |
| 54 | + 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; | |
| 56 | + | |
| 57 | + if (topright_ref == PART_NOT_AVAILABLE | |
| 58 | + && i >= scan8[0] + 8 && (i & 7) == 4 | |
| 59 | + && h->ref_cache[list][scan8[0] - 1] != PART_NOT_AVAILABLE) { | |
| 59 | 60 | const uint32_t *mb_types = s->current_picture_ptr->f.mb_type; |
| 60 | 61 | const int16_t *mv; |
| 61 | − AV_ZERO32(h->mv_cache[list][scan8[0]-2]); | |
| 62 | − *C = h->mv_cache[list][scan8[0]-2]; | |
| 62 | + AV_ZERO32(h->mv_cache[list][scan8[0] - 2]); | |
| 63 | + *C = h->mv_cache[list][scan8[0] - 2]; | |
| 63 | 64 | |
| 64 | − if(!MB_FIELD | |
| 65 | − && IS_INTERLACED(h->left_type[0])){ | |
| 66 | − SET_DIAG_MV(*2, >>1, h->left_mb_xy[0]+s->mb_stride, (s->mb_y&1)*2+(i>>5)); | |
| 65 | + if (!MB_FIELD && IS_INTERLACED(h->left_type[0])) { | |
| 66 | + SET_DIAG_MV(* 2, >> 1, h->left_mb_xy[0] + s->mb_stride, | |
| 67 | + (s->mb_y & 1) * 2 + (i >> 5)); | |
| 67 | 68 | } |
| 68 | − if(MB_FIELD | |
| 69 | − && !IS_INTERLACED(h->left_type[0])){ | |
| 69 | + if (MB_FIELD && !IS_INTERLACED(h->left_type[0])) { | |
| 70 | 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 | 74 | #undef SET_DIAG_MV |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | − if(topright_ref != PART_NOT_AVAILABLE){ | |
| 78 | − *C= h->mv_cache[list][ i - 8 + part_width ]; | |
| 77 | + if (topright_ref != PART_NOT_AVAILABLE) { | |
| 78 | + *C = h->mv_cache[list][i - 8 + part_width]; | |
| 79 | 79 | return topright_ref; |
| 80 | − }else{ | |
| 80 | + } else { | |
| 81 | 81 | tprintf(s->avctx, "topright MV not available\n"); |
| 82 | 82 | |
| 83 | − *C= h->mv_cache[list][ i - 8 - 1 ]; | |
| 84 | − return h->ref_cache[list][ i - 8 - 1 ]; | |
| 83 | + *C = h->mv_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 | 92 | * @param mx the x component of the predicted motion vector |
| 93 | 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){ | |
| 96 | − const int index8= scan8[n]; | |
| 97 | − const int top_ref= h->ref_cache[list][ index8 - 8 ]; | |
| 98 | − const int left_ref= h->ref_cache[list][ index8 - 1 ]; | |
| 99 | − const int16_t * const A= h->mv_cache[list][ index8 - 1 ]; | |
| 100 | − const int16_t * const B= h->mv_cache[list][ index8 - 8 ]; | |
| 101 | − const int16_t * C; | |
| 95 | +static av_always_inline void pred_motion(H264Context *const h, int n, | |
| 96 | + int part_width, int list, int ref, | |
| 97 | + int *const mx, int *const my) | |
| 98 | +{ | |
| 99 | + const int index8 = scan8[n]; | |
| 100 | + const int top_ref = h->ref_cache[list][index8 - 8]; | |
| 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 | 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 | 109 | /* mv_cache |
| 107 | − B . . A T T T T | |
| 108 | − U . . L . . , . | |
| 109 | − U . . L . . . . | |
| 110 | − U . . L . . , . | |
| 111 | − . . . L . . . . | |
| 112 | −*/ | |
| 113 | − | |
| 114 | − diagonal_ref= fetch_diagonal_mv(h, &C, index8, list, part_width); | |
| 115 | − match_count= (diagonal_ref==ref) + (top_ref==ref) + (left_ref==ref); | |
| 110 | + * B . . A T T T T | |
| 111 | + * U . . L . . , . | |
| 112 | + * U . . L . . . . | |
| 113 | + * U . . L . . , . | |
| 114 | + * . . . L . . . . | |
| 115 | + */ | |
| 116 | + | |
| 117 | + diagonal_ref = fetch_diagonal_mv(h, &C, index8, list, part_width); | |
| 118 | + match_count = (diagonal_ref == ref) + (top_ref == ref) + (left_ref == ref); | |
| 116 | 119 | tprintf(h->s.avctx, "pred_motion match_count=%d\n", match_count); |
| 117 | − if(match_count > 1){ //most common | |
| 118 | − *mx= mid_pred(A[0], B[0], C[0]); | |
| 119 | − *my= mid_pred(A[1], B[1], C[1]); | |
| 120 | − }else if(match_count==1){ | |
| 121 | − if(left_ref==ref){ | |
| 122 | − *mx= A[0]; | |
| 123 | − *my= A[1]; | |
| 124 | − }else if(top_ref==ref){ | |
| 125 | − *mx= B[0]; | |
| 126 | − *my= B[1]; | |
| 127 | − }else{ | |
| 128 | − *mx= C[0]; | |
| 129 | − *my= C[1]; | |
| 120 | + if (match_count > 1) { //most common | |
| 121 | + *mx = mid_pred(A[0], B[0], C[0]); | |
| 122 | + *my = mid_pred(A[1], B[1], C[1]); | |
| 123 | + } else if (match_count == 1) { | |
| 124 | + if (left_ref == ref) { | |
| 125 | + *mx = A[0]; | |
| 126 | + *my = A[1]; | |
| 127 | + } else if (top_ref == ref) { | |
| 128 | + *mx = B[0]; | |
| 129 | + *my = B[1]; | |
| 130 | + } else { | |
| 131 | + *mx = C[0]; | |
| 132 | + *my = C[1]; | |
| 130 | 133 | } |
| 131 | − }else{ | |
| 132 | − if(top_ref == PART_NOT_AVAILABLE && diagonal_ref == PART_NOT_AVAILABLE && left_ref != PART_NOT_AVAILABLE){ | |
| 133 | − *mx= A[0]; | |
| 134 | − *my= A[1]; | |
| 135 | − }else{ | |
| 136 | − *mx= mid_pred(A[0], B[0], C[0]); | |
| 137 | − *my= mid_pred(A[1], B[1], C[1]); | |
| 134 | + } else { | |
| 135 | + if (top_ref == PART_NOT_AVAILABLE && | |
| 136 | + diagonal_ref == PART_NOT_AVAILABLE && | |
| 137 | + left_ref != PART_NOT_AVAILABLE) { | |
| 138 | + *mx = A[0]; | |
| 139 | + *my = A[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 | 155 | * @param mx the x component of the predicted motion vector |
| 148 | 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){ | |
| 151 | − if(n==0){ | |
| 152 | − const int top_ref= h->ref_cache[list][ scan8[0] - 8 ]; | |
| 153 | − const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ]; | |
| 154 | − | |
| 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); | |
| 156 | − | |
| 157 | − if(top_ref == ref){ | |
| 158 | − *mx= B[0]; | |
| 159 | − *my= B[1]; | |
| 158 | +static av_always_inline void pred_16x8_motion(H264Context *const h, | |
| 159 | + int n, int list, int ref, | |
| 160 | + int *const mx, int *const my) | |
| 161 | +{ | |
| 162 | + if (n == 0) { | |
| 163 | + const int top_ref = h->ref_cache[list][scan8[0] - 8]; | |
| 164 | + const int16_t *const B = h->mv_cache[list][scan8[0] - 8]; | |
| 165 | + | |
| 166 | + tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", | |
| 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 | 172 | return; |
| 161 | 173 | } |
| 162 | − }else{ | |
| 163 | − const int left_ref= h->ref_cache[list][ scan8[8] - 1 ]; | |
| 164 | − const int16_t * const A= h->mv_cache[list][ scan8[8] - 1 ]; | |
| 174 | + } else { | |
| 175 | + const int left_ref = h->ref_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){ | |
| 169 | − *mx= A[0]; | |
| 170 | − *my= A[1]; | |
| 181 | + if (left_ref == ref) { | |
| 182 | + *mx = A[0]; | |
| 183 | + *my = A[1]; | |
| 171 | 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 | 195 | * @param mx the x component of the predicted motion vector |
| 183 | 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){ | |
| 186 | − if(n==0){ | |
| 187 | − const int left_ref= h->ref_cache[list][ scan8[0] - 1 ]; | |
| 188 | − const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ]; | |
| 189 | − | |
| 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); | |
| 191 | − | |
| 192 | − if(left_ref == ref){ | |
| 193 | − *mx= A[0]; | |
| 194 | − *my= A[1]; | |
| 198 | +static av_always_inline void pred_8x16_motion(H264Context *const h, | |
| 199 | + int n, int list, int ref, | |
| 200 | + int *const mx, int *const my) | |
| 201 | +{ | |
| 202 | + if (n == 0) { | |
| 203 | + const int left_ref = h->ref_cache[list][scan8[0] - 1]; | |
| 204 | + const int16_t *const A = h->mv_cache[list][scan8[0] - 1]; | |
| 205 | + | |
| 206 | + tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", | |
| 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 | 212 | return; |
| 196 | 213 | } |
| 197 | − }else{ | |
| 198 | − const int16_t * C; | |
| 214 | + } else { | |
| 215 | + const int16_t *C; | |
| 199 | 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){ | |
| 206 | − *mx= C[0]; | |
| 207 | − *my= C[1]; | |
| 223 | + if (diagonal_ref == ref) { | |
| 224 | + *mx = C[0]; | |
| 225 | + *my = C[1]; | |
| 208 | 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 | 231 | pred_motion(h, n, 2, list, ref, mx, my); |
| 214 | 232 | } |
| 215 | 233 | |
| 216 | −#define FIX_MV_MBAFF(type, refn, mvn, idx)\ | |
| 217 | − if(FRAME_MBAFF){\ | |
| 218 | − if(MB_FIELD){\ | |
| 219 | − if(!IS_INTERLACED(type)){\ | |
| 220 | − refn <<= 1;\ | |
| 221 | − AV_COPY32(mvbuf[idx], mvn);\ | |
| 222 | − mvbuf[idx][1] /= 2;\ | |
| 223 | − mvn = mvbuf[idx];\ | |
| 224 | − }\ | |
| 225 | − }else{\ | |
| 226 | − if(IS_INTERLACED(type)){\ | |
| 227 | − refn >>= 1;\ | |
| 228 | − AV_COPY32(mvbuf[idx], mvn);\ | |
| 229 | − mvbuf[idx][1] <<= 1;\ | |
| 230 | − mvn = mvbuf[idx];\ | |
| 231 | − }\ | |
| 232 | − }\ | |
| 234 | +#define FIX_MV_MBAFF(type, refn, mvn, idx) \ | |
| 235 | + if (FRAME_MBAFF) { \ | |
| 236 | + if (MB_FIELD) { \ | |
| 237 | + if (!IS_INTERLACED(type)) { \ | |
| 238 | + refn <<= 1; \ | |
| 239 | + AV_COPY32(mvbuf[idx], mvn); \ | |
| 240 | + mvbuf[idx][1] /= 2; \ | |
| 241 | + mvn = mvbuf[idx]; \ | |
| 242 | + } \ | |
| 243 | + } else { \ | |
| 244 | + if (IS_INTERLACED(type)) { \ | |
| 245 | + refn >>= 1; \ | |
| 246 | + AV_COPY32(mvbuf[idx], mvn); \ | |
| 247 | + mvbuf[idx][1] <<= 1; \ | |
| 248 | + mvn = mvbuf[idx]; \ | |
| 249 | + } \ | |
| 250 | + } \ | |
| 233 | 251 | } |
| 234 | 252 | |
| 235 | −static av_always_inline void pred_pskip_motion(H264Context * const h){ | |
| 236 | − DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = {0}; | |
| 253 | +static av_always_inline void pred_pskip_motion(H264Context *const h) | |
| 254 | +{ | |
| 255 | + DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = { 0 }; | |
| 237 | 256 | DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2]; |
| 238 | − MpegEncContext * const s = &h->s; | |
| 239 | − int8_t *ref = s->current_picture.f.ref_index[0]; | |
| 240 | − int16_t (*mv)[2] = s->current_picture.f.motion_val[0]; | |
| 257 | + MpegEncContext *const s = &h->s; | |
| 258 | + int8_t *ref = s->current_picture.f.ref_index[0]; | |
| 259 | + int16_t(*mv)[2] = s->current_picture.f.motion_val[0]; | |
| 241 | 260 | int top_ref, left_ref, diagonal_ref, match_count, mx, my; |
| 242 | 261 | const int16_t *A, *B, *C; |
| 243 | 262 | int b_stride = h->b_stride; |
| 244 | 263 | |
| 245 | 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. | |
| 248 | − * FIXME: this is a partial duplicate of the logic in fill_decode_caches, but it's | |
| 249 | − * faster this way. Is there a way to avoid this duplication? | |
| 266 | + /* To avoid doing an entire fill_decode_caches, we inline the relevant | |
| 267 | + * parts here. | |
| 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)){ | |
| 252 | − 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]]; | |
| 271 | + if (USES_LIST(h->left_type[LTOP], 0)) { | |
| 272 | + left_ref = ref[4 * h->left_mb_xy[LTOP] + 1 + (h->left_block[0] & ~1)]; | |
| 273 | + A = mv[h->mb2b_xy[h->left_mb_xy[LTOP]] + 3 + b_stride * h->left_block[0]]; | |
| 254 | 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 | 276 | goto zeromv; |
| 257 | − } | |
| 258 | − }else if(h->left_type[LTOP]){ | |
| 277 | + } else if (h->left_type[LTOP]) { | |
| 259 | 278 | left_ref = LIST_NOT_USED; |
| 260 | − A = zeromv; | |
| 261 | − }else{ | |
| 279 | + A = zeromv; | |
| 280 | + } else { | |
| 262 | 281 | goto zeromv; |
| 263 | 282 | } |
| 264 | 283 | |
| 265 | − if(USES_LIST(h->top_type, 0)){ | |
| 266 | − top_ref = ref[4*h->top_mb_xy + 2]; | |
| 267 | − B = mv[h->mb2b_xy[h->top_mb_xy] + 3*b_stride]; | |
| 284 | + if (USES_LIST(h->top_type, 0)) { | |
| 285 | + top_ref = ref[4 * h->top_mb_xy + 2]; | |
| 286 | + B = mv[h->mb2b_xy[h->top_mb_xy] + 3 * b_stride]; | |
| 268 | 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 | 289 | goto zeromv; |
| 271 | − } | |
| 272 | − }else if(h->top_type){ | |
| 290 | + } else if (h->top_type) { | |
| 273 | 291 | top_ref = LIST_NOT_USED; |
| 274 | − B = zeromv; | |
| 275 | − }else{ | |
| 292 | + B = zeromv; | |
| 293 | + } else { | |
| 276 | 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)){ | |
| 282 | − diagonal_ref = ref[4*h->topright_mb_xy + 2]; | |
| 283 | − C = mv[h->mb2b_xy[h->topright_mb_xy] + 3*b_stride]; | |
| 300 | + if (USES_LIST(h->topright_type, 0)) { | |
| 301 | + diagonal_ref = ref[4 * h->topright_mb_xy + 2]; | |
| 302 | + C = mv[h->mb2b_xy[h->topright_mb_xy] + 3 * b_stride]; | |
| 284 | 303 | FIX_MV_MBAFF(h->topright_type, diagonal_ref, C, 2); |
| 285 | − }else if(h->topright_type){ | |
| 304 | + } else if (h->topright_type) { | |
| 286 | 305 | diagonal_ref = LIST_NOT_USED; |
| 287 | 306 | C = zeromv; |
| 288 | − }else{ | |
| 289 | − if(USES_LIST(h->topleft_type, 0)){ | |
| 290 | − diagonal_ref = ref[4*h->topleft_mb_xy + 1 + (h->topleft_partition & 2)]; | |
| 291 | − C = mv[h->mb2b_xy[h->topleft_mb_xy] + 3 + b_stride + (h->topleft_partition & 2*b_stride)]; | |
| 307 | + } else { | |
| 308 | + if (USES_LIST(h->topleft_type, 0)) { | |
| 309 | + diagonal_ref = ref[4 * h->topleft_mb_xy + 1 + | |
| 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 | 313 | FIX_MV_MBAFF(h->topleft_type, diagonal_ref, C, 2); |
| 293 | − }else if(h->topleft_type){ | |
| 314 | + } else if (h->topleft_type) { | |
| 294 | 315 | diagonal_ref = LIST_NOT_USED; |
| 295 | − C = zeromv; | |
| 296 | − }else{ | |
| 316 | + C = zeromv; | |
| 317 | + } else { | |
| 297 | 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 | 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 | 326 | mx = mid_pred(A[0], B[0], C[0]); |
| 306 | 327 | my = mid_pred(A[1], B[1], C[1]); |
| 307 | − }else if(match_count==1){ | |
| 308 | − if(!left_ref){ | |
| 328 | + } else if (match_count == 1) { | |
| 329 | + if (!left_ref) { | |
| 309 | 330 | mx = A[0]; |
| 310 | 331 | my = A[1]; |
| 311 | − }else if(!top_ref){ | |
| 332 | + } else if (!top_ref) { | |
| 312 | 333 | mx = B[0]; |
| 313 | 334 | my = B[1]; |
| 314 | − }else{ | |
| 335 | + } else { | |
| 315 | 336 | mx = C[0]; |
| 316 | 337 | my = C[1]; |
| 317 | 338 | } |
| 318 | − }else{ | |
| 339 | + } else { | |
| 319 | 340 | mx = mid_pred(A[0], B[0], C[0]); |
| 320 | 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 | 345 | return; |
| 346 | + | |
| 325 | 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 | 349 | return; |
| 328 | 350 | } |
| 329 | 351 | |
| 330 | −static void fill_decode_neighbors(H264Context *h, int mb_type){ | |
| 331 | − MpegEncContext * const s = &h->s; | |
| 332 | − const int mb_xy= h->mb_xy; | |
| 352 | +static void fill_decode_neighbors(H264Context *h, int mb_type) | |
| 353 | +{ | |
| 354 | + MpegEncContext *const s = &h->s; | |
| 355 | + const int mb_xy = h->mb_xy; | |
| 333 | 356 | int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; |
| 334 | − 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}, | |
| 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}, | |
| 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}, | |
| 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} | |
| 357 | + static const uint8_t left_block_options[4][32] = { | |
| 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 }, | |
| 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 }, | |
| 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 }, | |
| 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 | 368 | /* Wow, what a mess, why didn't they simplify the interlacing & intra |
| 346 | 369 | * stuff, I can't imagine that these complex rules are worth it. */ |
| 347 | 370 | |
| 348 | − topleft_xy = top_xy - 1; | |
| 349 | − topright_xy= top_xy + 1; | |
| 350 | − left_xy[LBOT] = left_xy[LTOP] = mb_xy-1; | |
| 371 | + topleft_xy = top_xy - 1; | |
| 372 | + topright_xy = top_xy + 1; | |
| 373 | + left_xy[LBOT] = left_xy[LTOP] = mb_xy - 1; | |
| 351 | 374 | h->left_block = left_block_options[0]; |
| 352 | − if(FRAME_MBAFF){ | |
| 375 | + if (FRAME_MBAFF) { | |
| 353 | 376 | const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]); |
| 354 | 377 | const int curr_mb_field_flag = IS_INTERLACED(mb_type); |
| 355 | − if(s->mb_y&1){ | |
| 378 | + if (s->mb_y & 1) { | |
| 356 | 379 | if (left_mb_field_flag != curr_mb_field_flag) { |
| 357 | 380 | left_xy[LBOT] = left_xy[LTOP] = mb_xy - s->mb_stride - 1; |
| 358 | 381 | if (curr_mb_field_flag) { |
| 359 | 382 | left_xy[LBOT] += s->mb_stride; |
| 360 | − h->left_block = left_block_options[3]; | |
| 383 | + h->left_block = left_block_options[3]; | |
| 361 | 384 | } else { |
| 362 | 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 | 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{ | |
| 369 | − if(curr_mb_field_flag){ | |
| 392 | + } else { | |
| 393 | + if (curr_mb_field_flag) { | |
| 370 | 394 | topleft_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy - 1] >> 7) & 1) - 1); |
| 371 | 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 | 398 | if (left_mb_field_flag != curr_mb_field_flag) { |
| 375 | 399 | if (curr_mb_field_flag) { |
| 376 | 400 | left_xy[LBOT] += s->mb_stride; |
| 377 | − h->left_block = left_block_options[3]; | |
| 401 | + h->left_block = left_block_options[3]; | |
| 378 | 402 | } else { |
| 379 | 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; | |
| 386 | − h->top_mb_xy = top_xy; | |
| 387 | − h->topright_mb_xy= topright_xy; | |
| 409 | + h->topleft_mb_xy = topleft_xy; | |
| 410 | + h->top_mb_xy = top_xy; | |
| 411 | + h->topright_mb_xy = topright_xy; | |
| 388 | 412 | h->left_mb_xy[LTOP] = left_xy[LTOP]; |
| 389 | 413 | h->left_mb_xy[LBOT] = left_xy[LBOT]; |
| 390 | 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 | 419 | h->left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]]; |
| 396 | 420 | h->left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]]; |
| 397 | 421 | |
| 398 | − if(FMO){ | |
| 399 | − if(h->slice_table[topleft_xy ] != h->slice_num) h->topleft_type = 0; | |
| 400 | − if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0; | |
| 401 | − if(h->slice_table[left_xy[LTOP] ] != h->slice_num) h->left_type[LTOP] = h->left_type[LBOT] = 0; | |
| 402 | − }else{ | |
| 403 | − if(h->slice_table[topleft_xy ] != h->slice_num){ | |
| 422 | + if (FMO) { | |
| 423 | + if (h->slice_table[topleft_xy] != h->slice_num) | |
| 424 | + h->topleft_type = 0; | |
| 425 | + if (h->slice_table[top_xy] != h->slice_num) | |
| 426 | + h->top_type = 0; | |
| 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 | 431 | h->topleft_type = 0; |
| 405 | − if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0; | |
| 406 | − if(h->slice_table[left_xy[LTOP] ] != h->slice_num) h->left_type[LTOP] = h->left_type[LBOT] = 0; | |
| 432 | + if (h->slice_table[top_xy] != h->slice_num) | |
| 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){ | |
| 413 | − MpegEncContext * const s = &h->s; | |
| 442 | +static void fill_decode_caches(H264Context *h, int mb_type) | |
| 443 | +{ | |
| 444 | + MpegEncContext *const s = &h->s; | |
| 414 | 445 | int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; |
| 415 | 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 | 448 | int i; |
| 418 | 449 | uint8_t *nnz; |
| 419 | 450 | uint8_t *nnz_cache; |
| 420 | 451 | |
| 421 | − topleft_xy = h->topleft_mb_xy; | |
| 422 | − top_xy = h->top_mb_xy; | |
| 423 | − topright_xy = h->topright_mb_xy; | |
| 424 | − left_xy[LTOP] = h->left_mb_xy[LTOP]; | |
| 425 | − left_xy[LBOT] = h->left_mb_xy[LBOT]; | |
| 426 | − topleft_type = h->topleft_type; | |
| 427 | − top_type = h->top_type; | |
| 428 | − topright_type = h->topright_type; | |
| 429 | − left_type[LTOP]= h->left_type[LTOP]; | |
| 430 | − left_type[LBOT]= h->left_type[LBOT]; | |
| 431 | − | |
| 432 | − if(!IS_SKIP(mb_type)){ | |
| 433 | − if(IS_INTRA(mb_type)){ | |
| 434 | − int type_mask= h->pps.constrained_intra_pred ? IS_INTRA(-1) : -1; | |
| 435 | − h->topleft_samples_available= | |
| 436 | − h->top_samples_available= | |
| 437 | − h->left_samples_available= 0xFFFF; | |
| 438 | − h->topright_samples_available= 0xEEEA; | |
| 439 | − | |
| 440 | − if(!(top_type & type_mask)){ | |
| 441 | − h->topleft_samples_available= 0xB3FF; | |
| 442 | − h->top_samples_available= 0x33FF; | |
| 443 | − h->topright_samples_available= 0x26EA; | |
| 452 | + topleft_xy = h->topleft_mb_xy; | |
| 453 | + top_xy = h->top_mb_xy; | |
| 454 | + topright_xy = h->topright_mb_xy; | |
| 455 | + left_xy[LTOP] = h->left_mb_xy[LTOP]; | |
| 456 | + left_xy[LBOT] = h->left_mb_xy[LBOT]; | |
| 457 | + topleft_type = h->topleft_type; | |
| 458 | + top_type = h->top_type; | |
| 459 | + topright_type = h->topright_type; | |
| 460 | + left_type[LTOP] = h->left_type[LTOP]; | |
| 461 | + left_type[LBOT] = h->left_type[LBOT]; | |
| 462 | + | |
| 463 | + if (!IS_SKIP(mb_type)) { | |
| 464 | + if (IS_INTRA(mb_type)) { | |
| 465 | + int type_mask = h->pps.constrained_intra_pred ? IS_INTRA(-1) : -1; | |
| 466 | + h->topleft_samples_available = | |
| 467 | + h->top_samples_available = | |
| 468 | + h->left_samples_available = 0xFFFF; | |
| 469 | + h->topright_samples_available = 0xEEEA; | |
| 470 | + | |
| 471 | + if (!(top_type & type_mask)) { | |
| 472 | + h->topleft_samples_available = 0xB3FF; | |
| 473 | + h->top_samples_available = 0x33FF; | |
| 474 | + h->topright_samples_available = 0x26EA; | |
| 444 | 475 | } |
| 445 | − if(IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])){ | |
| 446 | − if(IS_INTERLACED(mb_type)){ | |
| 447 | − if(!(left_type[LTOP] & type_mask)){ | |
| 448 | − h->topleft_samples_available&= 0xDFFF; | |
| 449 | − h->left_samples_available&= 0x5FFF; | |
| 476 | + if (IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])) { | |
| 477 | + if (IS_INTERLACED(mb_type)) { | |
| 478 | + if (!(left_type[LTOP] & type_mask)) { | |
| 479 | + h->topleft_samples_available &= 0xDFFF; | |
| 480 | + h->left_samples_available &= 0x5FFF; | |
| 450 | 481 | } |
| 451 | − if(!(left_type[LBOT] & type_mask)){ | |
| 452 | − h->topleft_samples_available&= 0xFF5F; | |
| 453 | − h->left_samples_available&= 0xFF5F; | |
| 482 | + if (!(left_type[LBOT] & type_mask)) { | |
| 483 | + h->topleft_samples_available &= 0xFF5F; | |
| 484 | + h->left_samples_available &= 0xFF5F; | |
| 454 | 485 | } |
| 455 | − }else{ | |
| 486 | + } else { | |
| 456 | 487 | int left_typei = s->current_picture.f.mb_type[left_xy[LTOP] + s->mb_stride]; |
| 457 | 488 | |
| 458 | 489 | assert(left_xy[LTOP] == left_xy[LBOT]); |
| 459 | − if(!((left_typei & type_mask) && (left_type[LTOP] & type_mask))){ | |
| 460 | − h->topleft_samples_available&= 0xDF5F; | |
| 461 | − h->left_samples_available&= 0x5F5F; | |
| 490 | + if (!((left_typei & type_mask) && (left_type[LTOP] & type_mask))) { | |
| 491 | + h->topleft_samples_available &= 0xDF5F; | |
| 492 | + h->left_samples_available &= 0x5F5F; | |
| 462 | 493 | } |
| 463 | 494 | } |
| 464 | − }else{ | |
| 465 | − if(!(left_type[LTOP] & type_mask)){ | |
| 466 | − h->topleft_samples_available&= 0xDF5F; | |
| 467 | − h->left_samples_available&= 0x5F5F; | |
| 495 | + } else { | |
| 496 | + if (!(left_type[LTOP] & type_mask)) { | |
| 497 | + h->topleft_samples_available &= 0xDF5F; | |
| 498 | + h->left_samples_available &= 0x5F5F; | |
| 468 | 499 | } |
| 469 | 500 | } |
| 470 | 501 | |
| 471 | − if(!(topleft_type & type_mask)) | |
| 472 | − h->topleft_samples_available&= 0x7FFF; | |
| 502 | + if (!(topleft_type & type_mask)) | |
| 503 | + h->topleft_samples_available &= 0x7FFF; | |
| 473 | 504 | |
| 474 | − if(!(topright_type & type_mask)) | |
| 475 | − h->topright_samples_available&= 0xFBFF; | |
| 505 | + if (!(topright_type & type_mask)) | |
| 506 | + h->topright_samples_available &= 0xFBFF; | |
| 476 | 507 | |
| 477 | − if(IS_INTRA4x4(mb_type)){ | |
| 478 | − 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]); | |
| 480 | − }else{ | |
| 481 | − h->intra4x4_pred_mode_cache[4+8*0]= | |
| 482 | − h->intra4x4_pred_mode_cache[5+8*0]= | |
| 483 | − h->intra4x4_pred_mode_cache[6+8*0]= | |
| 484 | − h->intra4x4_pred_mode_cache[7+8*0]= 2 - 3*!(top_type & type_mask); | |
| 508 | + if (IS_INTRA4x4(mb_type)) { | |
| 509 | + if (IS_INTRA4x4(top_type)) { | |
| 510 | + AV_COPY32(h->intra4x4_pred_mode_cache + 4 + 8 * 0, h->intra4x4_pred_mode + h->mb2br_xy[top_xy]); | |
| 511 | + } else { | |
| 512 | + h->intra4x4_pred_mode_cache[4 + 8 * 0] = | |
| 513 | + h->intra4x4_pred_mode_cache[5 + 8 * 0] = | |
| 514 | + h->intra4x4_pred_mode_cache[6 + 8 * 0] = | |
| 515 | + h->intra4x4_pred_mode_cache[7 + 8 * 0] = 2 - 3 * !(top_type & type_mask); | |
| 485 | 516 | } |
| 486 | − for(i=0; i<2; i++){ | |
| 487 | − if(IS_INTRA4x4(left_type[LEFT(i)])){ | |
| 488 | − 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]]; | |
| 490 | − h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= mode[6-left_block[1+2*i]]; | |
| 491 | − }else{ | |
| 492 | − 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); | |
| 517 | + for (i = 0; i < 2; i++) { | |
| 518 | + if (IS_INTRA4x4(left_type[LEFT(i)])) { | |
| 519 | + int8_t *mode = h->intra4x4_pred_mode + h->mb2br_xy[left_xy[LEFT(i)]]; | |
| 520 | + h->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] = mode[6 - left_block[0 + 2 * i]]; | |
| 521 | + h->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = mode[6 - left_block[1 + 2 * i]]; | |
| 522 | + } else { | |
| 523 | + h->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] = | |
| 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 | − | |
| 500 | −/* | |
| 501 | −0 . T T. T T T T | |
| 502 | −1 L . .L . . . . | |
| 503 | −2 L . .L . . . . | |
| 504 | −3 . T TL . . . . | |
| 505 | −4 L . .L . . . . | |
| 506 | −5 L . .. . . . . | |
| 507 | −*/ | |
| 508 | −//FIXME constraint_intra_pred & partitioning & nnz (let us hope this is just a typo in the spec) | |
| 509 | − nnz_cache = h->non_zero_count_cache; | |
| 510 | − if(top_type){ | |
| 511 | − nnz = h->non_zero_count[top_xy]; | |
| 512 | − AV_COPY32(&nnz_cache[4+8* 0], &nnz[4*3]); | |
| 513 | − if(!s->chroma_y_shift){ | |
| 514 | − AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 7]); | |
| 515 | − AV_COPY32(&nnz_cache[4+8*10], &nnz[4*11]); | |
| 516 | − }else{ | |
| 517 | − AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 5]); | |
| 518 | − AV_COPY32(&nnz_cache[4+8*10], &nnz[4* 9]); | |
| 530 | + /* | |
| 531 | + * 0 . T T. T T T T | |
| 532 | + * 1 L . .L . . . . | |
| 533 | + * 2 L . .L . . . . | |
| 534 | + * 3 . T TL . . . . | |
| 535 | + * 4 L . .L . . . . | |
| 536 | + * 5 L . .. . . . . | |
| 537 | + */ | |
| 538 | + /* FIXME: constraint_intra_pred & partitioning & nnz | |
| 539 | + * (let us hope this is just a typo in the spec) */ | |
| 540 | + nnz_cache = h->non_zero_count_cache; | |
| 541 | + if (top_type) { | |
| 542 | + nnz = h->non_zero_count[top_xy]; | |
| 543 | + AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[4 * 3]); | |
| 544 | + if (!s->chroma_y_shift) { | |
| 545 | + AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 7]); | |
| 546 | + AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 11]); | |
| 547 | + } else { | |
| 548 | + AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 5]); | |
| 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++) { | |
| 528 | − if(left_type[LEFT(i)]){ | |
| 529 | − 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]]; | |
| 531 | − nnz_cache[3+8* 2 + 2*8*i]= nnz[left_block[8+1+2*i]]; | |
| 532 | − if(CHROMA444){ | |
| 533 | − 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]; | |
| 535 | − 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]; | |
| 537 | − }else if(CHROMA422) { | |
| 538 | − 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]; | |
| 540 | − 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]; | |
| 542 | − }else{ | |
| 543 | − 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]]; | |
| 558 | + for (i = 0; i < 2; i++) { | |
| 559 | + if (left_type[LEFT(i)]) { | |
| 560 | + nnz = h->non_zero_count[left_xy[LEFT(i)]]; | |
| 561 | + nnz_cache[3 + 8 * 1 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i]]; | |
| 562 | + nnz_cache[3 + 8 * 2 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i]]; | |
| 563 | + if (CHROMA444) { | |
| 564 | + nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 4 * 4]; | |
| 565 | + nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 4 * 4]; | |
| 566 | + nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 8 * 4]; | |
| 567 | + nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 8 * 4]; | |
| 568 | + } else if (CHROMA422) { | |
| 569 | + nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 4 * 4]; | |
| 570 | + nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 4 * 4]; | |
| 571 | + nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 8 * 4]; | |
| 572 | + nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 8 * 4]; | |
| 573 | + } else { | |
| 574 | + nnz_cache[3 + 8 * 6 + 8 * i] = nnz[left_block[8 + 4 + 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 ) { | |
| 557 | − // top_cbp | |
| 558 | − if(top_type) { | |
| 559 | − h->top_cbp = h->cbp_table[top_xy]; | |
| 560 | − } else { | |
| 561 | − h->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; | |
| 562 | − } | |
| 563 | − // left_cbp | |
| 564 | − if (left_type[LTOP]) { | |
| 565 | − h->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0) | |
| 566 | − | ((h->cbp_table[left_xy[LTOP]]>>(left_block[0]&(~1)))&2) | |
| 567 | − | (((h->cbp_table[left_xy[LBOT]]>>(left_block[2]&(~1)))&2) << 2); | |
| 568 | − } else { | |
| 569 | − h->left_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; | |
| 587 | + if (CABAC) { | |
| 588 | + // top_cbp | |
| 589 | + if (top_type) | |
| 590 | + h->top_cbp = h->cbp_table[top_xy]; | |
| 591 | + else | |
| 592 | + h->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; | |
| 593 | + // left_cbp | |
| 594 | + if (left_type[LTOP]) { | |
| 595 | + h->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0) | | |
| 596 | + ((h->cbp_table[left_xy[LTOP]] >> (left_block[0] & (~1))) & 2) | | |
| 597 | + (((h->cbp_table[left_xy[LBOT]] >> (left_block[2] & (~1))) & 2) << 2); | |
| 598 | + } else { | |
| 599 | + 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 | 605 | int list; |
| 576 | 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 | 608 | int8_t *ref_cache = &h->ref_cache[list][scan8[0]]; |
| 579 | 609 | int8_t *ref = s->current_picture.f.ref_index[list]; |
| 580 | − int16_t (*mv_cache)[2] = &h->mv_cache[list][scan8[0]]; | |
| 581 | − int16_t (*mv)[2] = s->current_picture.f.motion_val[list]; | |
| 582 | − if(!USES_LIST(mb_type, list)){ | |
| 610 | + int16_t(*mv_cache)[2] = &h->mv_cache[list][scan8[0]]; | |
| 611 | + int16_t(*mv)[2] = s->current_picture.f.motion_val[list]; | |
| 612 | + if (!USES_LIST(mb_type, list)) | |
| 583 | 613 | continue; |
| 584 | − } | |
| 585 | 614 | assert(!(IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred)); |
| 586 | 615 | |
| 587 | − if(USES_LIST(top_type, list)){ | |
| 588 | − const int b_xy= h->mb2b_xy[top_xy] + 3*b_stride; | |
| 589 | − AV_COPY128(mv_cache[0 - 1*8], mv[b_xy + 0]); | |
| 590 | − ref_cache[0 - 1*8]= | |
| 591 | − ref_cache[1 - 1*8]= ref[4*top_xy + 2]; | |
| 592 | − ref_cache[2 - 1*8]= | |
| 593 | − ref_cache[3 - 1*8]= ref[4*top_xy + 3]; | |
| 594 | − }else{ | |
| 595 | − 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); | |
| 616 | + if (USES_LIST(top_type, list)) { | |
| 617 | + const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride; | |
| 618 | + AV_COPY128(mv_cache[0 - 1 * 8], mv[b_xy + 0]); | |
| 619 | + ref_cache[0 - 1 * 8] = | |
| 620 | + ref_cache[1 - 1 * 8] = ref[4 * top_xy + 2]; | |
| 621 | + ref_cache[2 - 1 * 8] = | |
| 622 | + ref_cache[3 - 1 * 8] = ref[4 * top_xy + 3]; | |
| 623 | + } else { | |
| 624 | + AV_ZERO128(mv_cache[0 - 1 * 8]); | |
| 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)){ | |
| 600 | − for(i=0; i<2; i++){ | |
| 601 | − int cache_idx = -1 + i*2*8; | |
| 602 | − if(USES_LIST(left_type[LEFT(i)], list)){ | |
| 603 | − const int b_xy= h->mb2b_xy[left_xy[LEFT(i)]] + 3; | |
| 604 | − 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]]); | |
| 606 | − AV_COPY32(mv_cache[cache_idx+8], mv[b_xy + b_stride*left_block[1+i*2]]); | |
| 607 | − ref_cache[cache_idx ]= ref[b8_xy + (left_block[0+i*2]&~1)]; | |
| 608 | − ref_cache[cache_idx+8]= ref[b8_xy + (left_block[1+i*2]&~1)]; | |
| 609 | − }else{ | |
| 610 | − AV_ZERO32(mv_cache[cache_idx ]); | |
| 611 | − AV_ZERO32(mv_cache[cache_idx+8]); | |
| 612 | − ref_cache[cache_idx ]= | |
| 613 | − ref_cache[cache_idx+8]= (left_type[LEFT(i)]) ? LIST_NOT_USED : PART_NOT_AVAILABLE; | |
| 629 | + if (mb_type & (MB_TYPE_16x8 | MB_TYPE_8x8)) { | |
| 630 | + for (i = 0; i < 2; i++) { | |
| 631 | + int cache_idx = -1 + i * 2 * 8; | |
| 632 | + if (USES_LIST(left_type[LEFT(i)], list)) { | |
| 633 | + const int b_xy = h->mb2b_xy[left_xy[LEFT(i)]] + 3; | |
| 634 | + const int b8_xy = 4 * left_xy[LEFT(i)] + 1; | |
| 635 | + AV_COPY32(mv_cache[cache_idx], | |
| 636 | + mv[b_xy + b_stride * left_block[0 + i * 2]]); | |
| 637 | + AV_COPY32(mv_cache[cache_idx + 8], | |
| 638 | + mv[b_xy + b_stride * left_block[1 + i * 2]]); | |
| 639 | + ref_cache[cache_idx] = ref[b8_xy + (left_block[0 + i * 2] & ~1)]; | |
| 640 | + ref_cache[cache_idx + 8] = ref[b8_xy + (left_block[1 + i * 2] & ~1)]; | |
| 641 | + } else { | |
| 642 | + AV_ZERO32(mv_cache[cache_idx]); | |
| 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 | − } | |
| 616 | − }else{ | |
| 617 | − if(USES_LIST(left_type[LTOP], list)){ | |
| 618 | − const int b_xy= h->mb2b_xy[left_xy[LTOP]] + 3; | |
| 619 | − const int b8_xy= 4*left_xy[LTOP] + 1; | |
| 620 | − AV_COPY32(mv_cache[-1], mv[b_xy + b_stride*left_block[0]]); | |
| 621 | − ref_cache[-1]= ref[b8_xy + (left_block[0]&~1)]; | |
| 622 | − }else{ | |
| 649 | + } else { | |
| 650 | + if (USES_LIST(left_type[LTOP], list)) { | |
| 651 | + const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3; | |
| 652 | + const int b8_xy = 4 * left_xy[LTOP] + 1; | |
| 653 | + AV_COPY32(mv_cache[-1], mv[b_xy + b_stride * left_block[0]]); | |
| 654 | + ref_cache[-1] = ref[b8_xy + (left_block[0] & ~1)]; | |
| 655 | + } else { | |
| 623 | 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)){ | |
| 629 | − const int b_xy= h->mb2b_xy[topright_xy] + 3*b_stride; | |
| 630 | − AV_COPY32(mv_cache[4 - 1*8], mv[b_xy]); | |
| 631 | − ref_cache[4 - 1*8]= ref[4*topright_xy + 2]; | |
| 632 | − }else{ | |
| 633 | − AV_ZERO32(mv_cache[4 - 1*8]); | |
| 634 | − ref_cache[4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; | |
| 662 | + if (USES_LIST(topright_type, list)) { | |
| 663 | + const int b_xy = h->mb2b_xy[topright_xy] + 3 * b_stride; | |
| 664 | + AV_COPY32(mv_cache[4 - 1 * 8], mv[b_xy]); | |
| 665 | + ref_cache[4 - 1 * 8] = ref[4 * topright_xy + 2]; | |
| 666 | + } else { | |
| 667 | + AV_ZERO32(mv_cache[4 - 1 * 8]); | |
| 668 | + ref_cache[4 - 1 * 8] = topright_type ? LIST_NOT_USED | |
| 669 | + : PART_NOT_AVAILABLE; | |
| 635 | 670 | } |
| 636 | 671 | if(ref_cache[2 - 1*8] < 0 || ref_cache[4 - 1*8] < 0){ |
| 637 | − 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); | |
| 639 | − const int b8_xy= 4*topleft_xy + 1 + (h->topleft_partition & 2); | |
| 640 | − AV_COPY32(mv_cache[-1 - 1*8], mv[b_xy]); | |
| 641 | − ref_cache[-1 - 1*8]= ref[b8_xy]; | |
| 642 | − }else{ | |
| 643 | − AV_ZERO32(mv_cache[-1 - 1*8]); | |
| 644 | − ref_cache[-1 - 1*8]= topleft_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; | |
| 672 | + if (USES_LIST(topleft_type, list)) { | |
| 673 | + const int b_xy = h->mb2b_xy[topleft_xy] + 3 + b_stride + | |
| 674 | + (h->topleft_partition & 2 * b_stride); | |
| 675 | + const int b8_xy = 4 * topleft_xy + 1 + (h->topleft_partition & 2); | |
| 676 | + AV_COPY32(mv_cache[-1 - 1 * 8], mv[b_xy]); | |
| 677 | + ref_cache[-1 - 1 * 8] = ref[b8_xy]; | |
| 678 | + } else { | |
| 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 | 686 | continue; |
| 650 | 687 | |
| 651 | − if(!(mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2))){ | |
| 652 | − uint8_t (*mvd_cache)[2] = &h->mvd_cache[list][scan8[0]]; | |
| 653 | − uint8_t (*mvd)[2] = h->mvd_table[list]; | |
| 654 | − ref_cache[2+8*0] = | |
| 655 | − ref_cache[2+8*2] = PART_NOT_AVAILABLE; | |
| 656 | − AV_ZERO32(mv_cache[2+8*0]); | |
| 657 | − AV_ZERO32(mv_cache[2+8*2]); | |
| 658 | − | |
| 659 | − if( CABAC ) { | |
| 660 | − if(USES_LIST(top_type, list)){ | |
| 661 | − const int b_xy= h->mb2br_xy[top_xy]; | |
| 662 | − AV_COPY64(mvd_cache[0 - 1*8], mvd[b_xy + 0]); | |
| 663 | − }else{ | |
| 664 | − AV_ZERO64(mvd_cache[0 - 1*8]); | |
| 688 | + if (!(mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2))) { | |
| 689 | + uint8_t(*mvd_cache)[2] = &h->mvd_cache[list][scan8[0]]; | |
| 690 | + uint8_t(*mvd)[2] = h->mvd_table[list]; | |
| 691 | + ref_cache[2 + 8 * 0] = | |
| 692 | + ref_cache[2 + 8 * 2] = PART_NOT_AVAILABLE; | |
| 693 | + AV_ZERO32(mv_cache[2 + 8 * 0]); | |
| 694 | + AV_ZERO32(mv_cache[2 + 8 * 2]); | |
| 695 | + | |
| 696 | + if (CABAC) { | |
| 697 | + if (USES_LIST(top_type, list)) { | |
| 698 | + const int b_xy = h->mb2br_xy[top_xy]; | |
| 699 | + AV_COPY64(mvd_cache[0 - 1 * 8], mvd[b_xy + 0]); | |
| 700 | + } else { | |
| 701 | + AV_ZERO64(mvd_cache[0 - 1 * 8]); | |
| 665 | 702 | } |
| 666 | − if(USES_LIST(left_type[LTOP], list)){ | |
| 667 | − 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]]); | |
| 669 | − AV_COPY16(mvd_cache[-1 + 1*8], mvd[b_xy - left_block[1]]); | |
| 670 | − }else{ | |
| 671 | − AV_ZERO16(mvd_cache[-1 + 0*8]); | |
| 672 | − AV_ZERO16(mvd_cache[-1 + 1*8]); | |
| 703 | + if (USES_LIST(left_type[LTOP], list)) { | |
| 704 | + const int b_xy = h->mb2br_xy[left_xy[LTOP]] + 6; | |
| 705 | + AV_COPY16(mvd_cache[-1 + 0 * 8], mvd[b_xy - left_block[0]]); | |
| 706 | + AV_COPY16(mvd_cache[-1 + 1 * 8], mvd[b_xy - left_block[1]]); | |
| 707 | + } else { | |
| 708 | + AV_ZERO16(mvd_cache[-1 + 0 * 8]); | |
| 709 | + AV_ZERO16(mvd_cache[-1 + 1 * 8]); | |
| 673 | 710 | } |
| 674 | − if(USES_LIST(left_type[LBOT], list)){ | |
| 675 | − 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]]); | |
| 677 | − AV_COPY16(mvd_cache[-1 + 3*8], mvd[b_xy - left_block[3]]); | |
| 678 | − }else{ | |
| 679 | − AV_ZERO16(mvd_cache[-1 + 2*8]); | |
| 680 | − AV_ZERO16(mvd_cache[-1 + 3*8]); | |
| 711 | + if (USES_LIST(left_type[LBOT], list)) { | |
| 712 | + const int b_xy = h->mb2br_xy[left_xy[LBOT]] + 6; | |
| 713 | + AV_COPY16(mvd_cache[-1 + 2 * 8], mvd[b_xy - left_block[2]]); | |
| 714 | + AV_COPY16(mvd_cache[-1 + 3 * 8], mvd[b_xy - left_block[3]]); | |
| 715 | + } else { | |
| 716 | + AV_ZERO16(mvd_cache[-1 + 2 * 8]); | |
| 717 | + AV_ZERO16(mvd_cache[-1 + 3 * 8]); | |
| 681 | 718 | } |
| 682 | − AV_ZERO16(mvd_cache[2+8*0]); | |
| 683 | − AV_ZERO16(mvd_cache[2+8*2]); | |
| 684 | − if(h->slice_type_nos == AV_PICTURE_TYPE_B){ | |
| 719 | + AV_ZERO16(mvd_cache[2 + 8 * 0]); | |
| 720 | + AV_ZERO16(mvd_cache[2 + 8 * 2]); | |
| 721 | + if (h->slice_type_nos == AV_PICTURE_TYPE_B) { | |
| 685 | 722 | uint8_t *direct_cache = &h->direct_cache[scan8[0]]; |
| 686 | 723 | uint8_t *direct_table = h->direct_table; |
| 687 | − fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16>>1, 1); | |
| 688 | − | |
| 689 | − if(IS_DIRECT(top_type)){ | |
| 690 | − AV_WN32A(&direct_cache[-1*8], 0x01010101u*(MB_TYPE_DIRECT2>>1)); | |
| 691 | − }else if(IS_8X8(top_type)){ | |
| 692 | − int b8_xy = 4*top_xy; | |
| 693 | − direct_cache[0 - 1*8]= direct_table[b8_xy + 2]; | |
| 694 | − direct_cache[2 - 1*8]= direct_table[b8_xy + 3]; | |
| 695 | − }else{ | |
| 696 | − AV_WN32A(&direct_cache[-1*8], 0x01010101*(MB_TYPE_16x16>>1)); | |
| 724 | + fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16 >> 1, 1); | |
| 725 | + | |
| 726 | + if (IS_DIRECT(top_type)) { | |
| 727 | + AV_WN32A(&direct_cache[-1 * 8], | |
| 728 | + 0x01010101u * (MB_TYPE_DIRECT2 >> 1)); | |
| 729 | + } else if (IS_8X8(top_type)) { | |
| 730 | + int b8_xy = 4 * top_xy; | |
| 731 | + direct_cache[0 - 1 * 8] = direct_table[b8_xy + 2]; | |
| 732 | + direct_cache[2 - 1 * 8] = direct_table[b8_xy + 3]; | |
| 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])) | |
| 700 | − direct_cache[-1 + 0*8]= MB_TYPE_DIRECT2>>1; | |
| 701 | − else if(IS_8X8(left_type[LTOP])) | |
| 702 | − direct_cache[-1 + 0*8]= direct_table[4*left_xy[LTOP] + 1 + (left_block[0]&~1)]; | |
| 738 | + if (IS_DIRECT(left_type[LTOP])) | |
| 739 | + direct_cache[-1 + 0 * 8] = MB_TYPE_DIRECT2 >> 1; | |
| 740 | + else if (IS_8X8(left_type[LTOP])) | |
| 741 | + direct_cache[-1 + 0 * 8] = direct_table[4 * left_xy[LTOP] + 1 + (left_block[0] & ~1)]; | |
| 703 | 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])) | |
| 707 | − direct_cache[-1 + 2*8]= MB_TYPE_DIRECT2>>1; | |
| 708 | − else if(IS_8X8(left_type[LBOT])) | |
| 709 | − direct_cache[-1 + 2*8]= direct_table[4*left_xy[LBOT] + 1 + (left_block[2]&~1)]; | |
| 745 | + if (IS_DIRECT(left_type[LBOT])) | |
| 746 | + direct_cache[-1 + 2 * 8] = MB_TYPE_DIRECT2 >> 1; | |
| 747 | + else if (IS_8X8(left_type[LBOT])) | |
| 748 | + direct_cache[-1 + 2 * 8] = direct_table[4 * left_xy[LBOT] + 1 + (left_block[2] & ~1)]; | |
| 710 | 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){ | |
| 716 | −#define MAP_MVS\ | |
| 717 | − MAP_F2F(scan8[0] - 1 - 1*8, topleft_type)\ | |
| 718 | − MAP_F2F(scan8[0] + 0 - 1*8, top_type)\ | |
| 719 | − MAP_F2F(scan8[0] + 1 - 1*8, top_type)\ | |
| 720 | − MAP_F2F(scan8[0] + 2 - 1*8, top_type)\ | |
| 721 | − MAP_F2F(scan8[0] + 3 - 1*8, top_type)\ | |
| 722 | − MAP_F2F(scan8[0] + 4 - 1*8, topright_type)\ | |
| 723 | − MAP_F2F(scan8[0] - 1 + 0*8, left_type[LTOP])\ | |
| 724 | − MAP_F2F(scan8[0] - 1 + 1*8, left_type[LTOP])\ | |
| 725 | − MAP_F2F(scan8[0] - 1 + 2*8, left_type[LBOT])\ | |
| 726 | − MAP_F2F(scan8[0] - 1 + 3*8, left_type[LBOT]) | |
| 727 | − if(MB_FIELD){ | |
| 728 | −#define MAP_F2F(idx, mb_type)\ | |
| 729 | − if(!IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\ | |
| 730 | − h->ref_cache[list][idx] <<= 1;\ | |
| 731 | − h->mv_cache[list][idx][1] /= 2;\ | |
| 732 | − h->mvd_cache[list][idx][1] >>=1;\ | |
| 733 | − } | |
| 754 | + | |
| 755 | +#define MAP_MVS \ | |
| 756 | + MAP_F2F(scan8[0] - 1 - 1 * 8, topleft_type) \ | |
| 757 | + MAP_F2F(scan8[0] + 0 - 1 * 8, top_type) \ | |
| 758 | + MAP_F2F(scan8[0] + 1 - 1 * 8, top_type) \ | |
| 759 | + MAP_F2F(scan8[0] + 2 - 1 * 8, top_type) \ | |
| 760 | + MAP_F2F(scan8[0] + 3 - 1 * 8, top_type) \ | |
| 761 | + MAP_F2F(scan8[0] + 4 - 1 * 8, topright_type) \ | |
| 762 | + MAP_F2F(scan8[0] - 1 + 0 * 8, left_type[LTOP]) \ | |
| 763 | + MAP_F2F(scan8[0] - 1 + 1 * 8, left_type[LTOP]) \ | |
| 764 | + MAP_F2F(scan8[0] - 1 + 2 * 8, left_type[LBOT]) \ | |
| 765 | + MAP_F2F(scan8[0] - 1 + 3 * 8, left_type[LBOT]) | |
| 766 | + | |
| 767 | + if (FRAME_MBAFF) { | |
| 768 | + if (MB_FIELD) { | |
| 769 | + | |
| 770 | +#define MAP_F2F(idx, mb_type) \ | |
| 771 | + if (!IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0) { \ | |
| 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 | 777 | MAP_MVS |
| 778 | + } else { | |
| 779 | + | |
| 735 | 780 | #undef MAP_F2F |
| 736 | − }else{ | |
| 737 | −#define MAP_F2F(idx, mb_type)\ | |
| 738 | − if(IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\ | |
| 739 | − h->ref_cache[list][idx] >>= 1;\ | |
| 740 | − h->mv_cache[list][idx][1] <<= 1;\ | |
| 741 | − h->mvd_cache[list][idx][1] <<= 1;\ | |
| 742 | − } | |
| 781 | +#define MAP_F2F(idx, mb_type) \ | |
| 782 | + if (IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0) { \ | |
| 783 | + h->ref_cache[list][idx] >>= 1; \ | |
| 784 | + h->mv_cache[list][idx][1] <<= 1; \ | |
| 785 | + h->mvd_cache[list][idx][1] <<= 1; \ | |
| 786 | + } | |
| 787 | + | |
| 743 | 788 | MAP_MVS |
| 744 | 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 | 799 | * decodes a P_SKIP or B_SKIP macroblock |
| 755 | 800 | */ |
| 756 | −static void av_unused decode_mb_skip(H264Context *h){ | |
| 757 | − MpegEncContext * const s = &h->s; | |
| 758 | − const int mb_xy= h->mb_xy; | |
| 759 | − int mb_type=0; | |
| 801 | +static void av_unused decode_mb_skip(H264Context *h) | |
| 802 | +{ | |
| 803 | + MpegEncContext *const s = &h->s; | |
| 804 | + const int mb_xy = h->mb_xy; | |
| 805 | + int mb_type = 0; | |
| 760 | 806 | |
| 761 | 807 | memset(h->non_zero_count[mb_xy], 0, 48); |
| 762 | 808 | |
| 763 | − if(MB_FIELD) | |
| 764 | − mb_type|= MB_TYPE_INTERLACED; | |
| 809 | + if (MB_FIELD) | |
| 810 | + mb_type |= MB_TYPE_INTERLACED; | |
| 765 | 811 | |
| 766 | − if( h->slice_type_nos == AV_PICTURE_TYPE_B ) | |
| 767 | − { | |
| 812 | + if (h->slice_type_nos == AV_PICTURE_TYPE_B) { | |
| 768 | 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; | |
| 770 | − if(h->direct_spatial_mv_pred){ | |
| 814 | + mb_type |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 | MB_TYPE_SKIP; | |
| 815 | + if (h->direct_spatial_mv_pred) { | |
| 771 | 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 | 819 | ff_h264_pred_direct_motion(h, &mb_type); |
| 775 | − mb_type|= MB_TYPE_SKIP; | |
| 776 | − } | |
| 777 | − else | |
| 778 | − { | |
| 779 | − mb_type|= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_SKIP; | |
| 820 | + mb_type |= MB_TYPE_SKIP; | |
| 821 | + } else { | |
| 822 | + mb_type |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_SKIP; | |
| 780 | 823 | |
| 781 | 824 | fill_decode_neighbors(h, mb_type); |
| 782 | 825 | pred_pskip_motion(h); |
| @@ -785,8 +828,8 @@ static void av_unused decode_mb_skip(H264Context *h){ · 2 unmodified lines | ||
| 785 | 828 | write_back_motion(h, mb_type); |
| 786 | 829 | s->current_picture.f.mb_type[mb_xy] = mb_type; |
| 787 | 830 | s->current_picture.f.qscale_table[mb_xy] = s->qscale; |
| 788 | − h->slice_table[ mb_xy ]= h->slice_num; | |
| 789 | − h->prev_mb_skipped= 1; | |
| 831 | + h->slice_table[mb_xy] = h->slice_num; | |
| 832 | + h->prev_mb_skipped = 1; | |
| 790 | 833 | } |
| 791 | 834 | |
| 792 | 835 | #endif /* AVCODEC_H264_MVPRED_H */ |
| @@ -30,240 +30,243 @@ · 29 unmodified lines | ||
| 30 | 30 | #define AVCODEC_H264DATA_H |
| 31 | 31 | |
| 32 | 32 | #include <stdint.h> |
| 33 | + | |
| 33 | 34 | #include "libavutil/rational.h" |
| 34 | 35 | #include "mpegvideo.h" |
| 35 | 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]= | |
| 39 | −{AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_SP, AV_PICTURE_TYPE_SI}; | |
| 40 | − | |
| 41 | −static const uint8_t golomb_to_intra4x4_cbp[48]={ | |
| 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 | |
| 43 | +static const uint8_t golomb_to_intra4x4_cbp[48] = { | |
| 44 | + 47, 31, 15, 0, 23, 27, 29, 30, 7, 11, 13, 14, 39, 43, 45, 46, | |
| 45 | + 16, 3, 5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44, 1, 2, 4, | |
| 46 | + 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]={ | |
| 48 | − 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, | |
| 50 | − 17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41 | |
| 49 | +static const uint8_t golomb_to_inter_cbp[48] = { | |
| 50 | + 0, 16, 1, 2, 4, 8, 32, 3, 5, 10, 12, 15, 47, 7, 11, 13, | |
| 51 | + 14, 6, 9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46, | |
| 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]={ | |
| 54 | − 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, | |
| 56 | − 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, | |
| 55 | +static const uint8_t zigzag_scan[16] = { | |
| 56 | + 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, | |
| 57 | + 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4, | |
| 58 | + 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 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]={ | |
| 61 | − 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, | |
| 63 | − 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, | |
| 62 | +static const uint8_t field_scan[16] = { | |
| 63 | + 0 + 0 * 4, 0 + 1 * 4, 1 + 0 * 4, 0 + 2 * 4, | |
| 64 | + 0 + 3 * 4, 1 + 1 * 4, 1 + 2 * 4, 1 + 3 * 4, | |
| 65 | + 2 + 0 * 4, 2 + 1 * 4, 2 + 2 * 4, 2 + 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]={ | |
| 68 | − 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, | |
| 70 | − 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, | |
| 69 | +static const uint8_t luma_dc_zigzag_scan[16] = { | |
| 70 | + 0 * 16 + 0 * 64, 1 * 16 + 0 * 64, 2 * 16 + 0 * 64, 0 * 16 + 2 * 64, | |
| 71 | + 3 * 16 + 0 * 64, 0 * 16 + 1 * 64, 1 * 16 + 1 * 64, 2 * 16 + 1 * 64, | |
| 72 | + 1 * 16 + 2 * 64, 2 * 16 + 2 * 64, 3 * 16 + 2 * 64, 0 * 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]={ | |
| 75 | − 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, | |
| 77 | − 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, | |
| 76 | +static const uint8_t luma_dc_field_scan[16] = { | |
| 77 | + 0 * 16 + 0 * 64, 2 * 16 + 0 * 64, 1 * 16 + 0 * 64, 0 * 16 + 2 * 64, | |
| 78 | + 2 * 16 + 2 * 64, 3 * 16 + 0 * 64, 1 * 16 + 2 * 64, 3 * 16 + 2 * 64, | |
| 79 | + 0 * 16 + 1 * 64, 2 * 16 + 1 * 64, 0 * 16 + 3 * 64, 2 * 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]={ | |
| 82 | − (0+0*2)*16, (1+0*2)*16, | |
| 83 | − (0+1*2)*16, (1+1*2)*16, | |
| 83 | +static const uint8_t chroma_dc_scan[4] = { | |
| 84 | + (0 + 0 * 2) * 16, (1 + 0 * 2) * 16, | |
| 85 | + (0 + 1 * 2) * 16, (1 + 1 * 2) * 16, | |
| 84 | 86 | }; |
| 85 | 87 | |
| 86 | −static const uint8_t chroma422_dc_scan[8]={ | |
| 87 | − (0+0*2)*16, (0+1*2)*16, | |
| 88 | − (1+0*2)*16, (0+2*2)*16, | |
| 89 | − (0+3*2)*16, (1+1*2)*16, | |
| 90 | − (1+2*2)*16, (1+3*2)*16, | |
| 88 | +static const uint8_t chroma422_dc_scan[8] = { | |
| 89 | + (0 + 0 * 2) * 16, (0 + 1 * 2) * 16, | |
| 90 | + (1 + 0 * 2) * 16, (0 + 2 * 2) * 16, | |
| 91 | + (0 + 3 * 2) * 16, (1 + 1 * 2) * 16, | |
| 92 | + (1 + 2 * 2) * 16, (1 + 3 * 2) * 16, | |
| 91 | 93 | }; |
| 92 | 94 | |
| 93 | 95 | // zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)] |
| 94 | −static const uint8_t zigzag_scan8x8_cavlc[64]={ | |
| 95 | − 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, | |
| 97 | − 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, | |
| 99 | − 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, | |
| 101 | − 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, | |
| 103 | − 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, | |
| 105 | − 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, | |
| 107 | − 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, | |
| 109 | − 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, | |
| 96 | +static const uint8_t zigzag_scan8x8_cavlc[64] = { | |
| 97 | + 0 + 0 * 8, 1 + 1 * 8, 1 + 2 * 8, 2 + 2 * 8, | |
| 98 | + 4 + 1 * 8, 0 + 5 * 8, 3 + 3 * 8, 7 + 0 * 8, | |
| 99 | + 3 + 4 * 8, 1 + 7 * 8, 5 + 3 * 8, 6 + 3 * 8, | |
| 100 | + 2 + 7 * 8, 6 + 4 * 8, 5 + 6 * 8, 7 + 5 * 8, | |
| 101 | + 1 + 0 * 8, 2 + 0 * 8, 0 + 3 * 8, 3 + 1 * 8, | |
| 102 | + 3 + 2 * 8, 0 + 6 * 8, 4 + 2 * 8, 6 + 1 * 8, | |
| 103 | + 2 + 5 * 8, 2 + 6 * 8, 6 + 2 * 8, 5 + 4 * 8, | |
| 104 | + 3 + 7 * 8, 7 + 3 * 8, 4 + 7 * 8, 7 + 6 * 8, | |
| 105 | + 0 + 1 * 8, 3 + 0 * 8, 0 + 4 * 8, 4 + 0 * 8, | |
| 106 | + 2 + 3 * 8, 1 + 5 * 8, 5 + 1 * 8, 5 + 2 * 8, | |
| 107 | + 1 + 6 * 8, 3 + 5 * 8, 7 + 1 * 8, 4 + 5 * 8, | |
| 108 | + 4 + 6 * 8, 7 + 4 * 8, 5 + 7 * 8, 6 + 7 * 8, | |
| 109 | + 0 + 2 * 8, 2 + 1 * 8, 1 + 3 * 8, 5 + 0 * 8, | |
| 110 | + 1 + 4 * 8, 2 + 4 * 8, 6 + 0 * 8, 4 + 3 * 8, | |
| 111 | + 0 + 7 * 8, 4 + 4 * 8, 7 + 2 * 8, 3 + 6 * 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]={ | |
| 114 | − 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, | |
| 116 | − 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, | |
| 118 | − 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, | |
| 120 | − 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, | |
| 122 | − 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, | |
| 124 | − 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, | |
| 126 | − 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, | |
| 128 | − 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, | |
| 115 | +static const uint8_t field_scan8x8[64] = { | |
| 116 | + 0 + 0 * 8, 0 + 1 * 8, 0 + 2 * 8, 1 + 0 * 8, | |
| 117 | + 1 + 1 * 8, 0 + 3 * 8, 0 + 4 * 8, 1 + 2 * 8, | |
| 118 | + 2 + 0 * 8, 1 + 3 * 8, 0 + 5 * 8, 0 + 6 * 8, | |
| 119 | + 0 + 7 * 8, 1 + 4 * 8, 2 + 1 * 8, 3 + 0 * 8, | |
| 120 | + 2 + 2 * 8, 1 + 5 * 8, 1 + 6 * 8, 1 + 7 * 8, | |
| 121 | + 2 + 3 * 8, 3 + 1 * 8, 4 + 0 * 8, 3 + 2 * 8, | |
| 122 | + 2 + 4 * 8, 2 + 5 * 8, 2 + 6 * 8, 2 + 7 * 8, | |
| 123 | + 3 + 3 * 8, 4 + 1 * 8, 5 + 0 * 8, 4 + 2 * 8, | |
| 124 | + 3 + 4 * 8, 3 + 5 * 8, 3 + 6 * 8, 3 + 7 * 8, | |
| 125 | + 4 + 3 * 8, 5 + 1 * 8, 6 + 0 * 8, 5 + 2 * 8, | |
| 126 | + 4 + 4 * 8, 4 + 5 * 8, 4 + 6 * 8, 4 + 7 * 8, | |
| 127 | + 5 + 3 * 8, 6 + 1 * 8, 6 + 2 * 8, 5 + 4 * 8, | |
| 128 | + 5 + 5 * 8, 5 + 6 * 8, 5 + 7 * 8, 6 + 3 * 8, | |
| 129 | + 7 + 0 * 8, 7 + 1 * 8, 6 + 4 * 8, 6 + 5 * 8, | |
| 130 | + 6 + 6 * 8, 6 + 7 * 8, 7 + 2 * 8, 7 + 3 * 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]={ | |
| 133 | − 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, | |
| 135 | − 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, | |
| 137 | − 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, | |
| 139 | − 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, | |
| 141 | − 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, | |
| 143 | − 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, | |
| 145 | − 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, | |
| 147 | − 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, | |
| 134 | +static const uint8_t field_scan8x8_cavlc[64] = { | |
| 135 | + 0 + 0 * 8, 1 + 1 * 8, 2 + 0 * 8, 0 + 7 * 8, | |
| 136 | + 2 + 2 * 8, 2 + 3 * 8, 2 + 4 * 8, 3 + 3 * 8, | |
| 137 | + 3 + 4 * 8, 4 + 3 * 8, 4 + 4 * 8, 5 + 3 * 8, | |
| 138 | + 5 + 5 * 8, 7 + 0 * 8, 6 + 6 * 8, 7 + 4 * 8, | |
| 139 | + 0 + 1 * 8, 0 + 3 * 8, 1 + 3 * 8, 1 + 4 * 8, | |
| 140 | + 1 + 5 * 8, 3 + 1 * 8, 2 + 5 * 8, 4 + 1 * 8, | |
| 141 | + 3 + 5 * 8, 5 + 1 * 8, 4 + 5 * 8, 6 + 1 * 8, | |
| 142 | + 5 + 6 * 8, 7 + 1 * 8, 6 + 7 * 8, 7 + 5 * 8, | |
| 143 | + 0 + 2 * 8, 0 + 4 * 8, 0 + 5 * 8, 2 + 1 * 8, | |
| 144 | + 1 + 6 * 8, 4 + 0 * 8, 2 + 6 * 8, 5 + 0 * 8, | |
| 145 | + 3 + 6 * 8, 6 + 0 * 8, 4 + 6 * 8, 6 + 2 * 8, | |
| 146 | + 5 + 7 * 8, 6 + 4 * 8, 7 + 2 * 8, 7 + 6 * 8, | |
| 147 | + 1 + 0 * 8, 1 + 2 * 8, 0 + 6 * 8, 3 + 0 * 8, | |
| 148 | + 1 + 7 * 8, 3 + 2 * 8, 2 + 7 * 8, 4 + 2 * 8, | |
| 149 | + 3 + 7 * 8, 5 + 2 * 8, 4 + 7 * 8, 5 + 4 * 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 | 154 | uint16_t type; |
| 153 | 155 | uint8_t pred_mode; |
| 154 | 156 | uint8_t cbp; |
| 155 | 157 | } IMbInfo; |
| 156 | 158 | |
| 157 | −static const IMbInfo i_mb_type_info[26]={ | |
| 158 | −{MB_TYPE_INTRA4x4 , -1, -1}, | |
| 159 | −{MB_TYPE_INTRA16x16, 2, 0}, | |
| 160 | −{MB_TYPE_INTRA16x16, 1, 0}, | |
| 161 | −{MB_TYPE_INTRA16x16, 0, 0}, | |
| 162 | −{MB_TYPE_INTRA16x16, 3, 0}, | |
| 163 | −{MB_TYPE_INTRA16x16, 2, 16}, | |
| 164 | −{MB_TYPE_INTRA16x16, 1, 16}, | |
| 165 | −{MB_TYPE_INTRA16x16, 0, 16}, | |
| 166 | −{MB_TYPE_INTRA16x16, 3, 16}, | |
| 167 | −{MB_TYPE_INTRA16x16, 2, 32}, | |
| 168 | −{MB_TYPE_INTRA16x16, 1, 32}, | |
| 169 | −{MB_TYPE_INTRA16x16, 0, 32}, | |
| 170 | −{MB_TYPE_INTRA16x16, 3, 32}, | |
| 171 | −{MB_TYPE_INTRA16x16, 2, 15+0}, | |
| 172 | −{MB_TYPE_INTRA16x16, 1, 15+0}, | |
| 173 | −{MB_TYPE_INTRA16x16, 0, 15+0}, | |
| 174 | −{MB_TYPE_INTRA16x16, 3, 15+0}, | |
| 175 | −{MB_TYPE_INTRA16x16, 2, 15+16}, | |
| 176 | −{MB_TYPE_INTRA16x16, 1, 15+16}, | |
| 177 | −{MB_TYPE_INTRA16x16, 0, 15+16}, | |
| 178 | −{MB_TYPE_INTRA16x16, 3, 15+16}, | |
| 179 | −{MB_TYPE_INTRA16x16, 2, 15+32}, | |
| 180 | −{MB_TYPE_INTRA16x16, 1, 15+32}, | |
| 181 | −{MB_TYPE_INTRA16x16, 0, 15+32}, | |
| 182 | −{MB_TYPE_INTRA16x16, 3, 15+32}, | |
| 183 | −{MB_TYPE_INTRA_PCM , -1, -1}, | |
| 159 | +static const IMbInfo i_mb_type_info[26] = { | |
| 160 | + { MB_TYPE_INTRA4x4, -1, -1 }, | |
| 161 | + { MB_TYPE_INTRA16x16, 2, 0 }, | |
| 162 | + { MB_TYPE_INTRA16x16, 1, 0 }, | |
| 163 | + { MB_TYPE_INTRA16x16, 0, 0 }, | |
| 164 | + { MB_TYPE_INTRA16x16, 3, 0 }, | |
| 165 | + { MB_TYPE_INTRA16x16, 2, 16 }, | |
| 166 | + { MB_TYPE_INTRA16x16, 1, 16 }, | |
| 167 | + { MB_TYPE_INTRA16x16, 0, 16 }, | |
| 168 | + { MB_TYPE_INTRA16x16, 3, 16 }, | |
| 169 | + { MB_TYPE_INTRA16x16, 2, 32 }, | |
| 170 | + { MB_TYPE_INTRA16x16, 1, 32 }, | |
| 171 | + { MB_TYPE_INTRA16x16, 0, 32 }, | |
| 172 | + { MB_TYPE_INTRA16x16, 3, 32 }, | |
| 173 | + { MB_TYPE_INTRA16x16, 2, 15 + 0 }, | |
| 174 | + { MB_TYPE_INTRA16x16, 1, 15 + 0 }, | |
| 175 | + { MB_TYPE_INTRA16x16, 0, 15 + 0 }, | |
| 176 | + { MB_TYPE_INTRA16x16, 3, 15 + 0 }, | |
| 177 | + { MB_TYPE_INTRA16x16, 2, 15 + 16 }, | |
| 178 | + { MB_TYPE_INTRA16x16, 1, 15 + 16 }, | |
| 179 | + { MB_TYPE_INTRA16x16, 0, 15 + 16 }, | |
| 180 | + { MB_TYPE_INTRA16x16, 3, 15 + 16 }, | |
| 181 | + { MB_TYPE_INTRA16x16, 2, 15 + 32 }, | |
| 182 | + { MB_TYPE_INTRA16x16, 1, 15 + 32 }, | |
| 183 | + { MB_TYPE_INTRA16x16, 0, 15 + 32 }, | |
| 184 | + { MB_TYPE_INTRA16x16, 3, 15 + 32 }, | |
| 185 | + { MB_TYPE_INTRA_PCM, -1, -1 }, | |
| 184 | 186 | }; |
| 185 | 187 | |
| 186 | −typedef struct PMbInfo{ | |
| 188 | +typedef struct PMbInfo { | |
| 187 | 189 | uint16_t type; |
| 188 | 190 | uint8_t partition_count; |
| 189 | 191 | } PMbInfo; |
| 190 | 192 | |
| 191 | −static const PMbInfo p_mb_type_info[5]={ | |
| 192 | −{MB_TYPE_16x16|MB_TYPE_P0L0 , 1}, | |
| 193 | −{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P1L0, 2}, | |
| 194 | −{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P1L0, 2}, | |
| 195 | −{MB_TYPE_8x8 |MB_TYPE_P0L0|MB_TYPE_P1L0, 4}, | |
| 196 | −{MB_TYPE_8x8 |MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_REF0, 4}, | |
| 193 | +static const PMbInfo p_mb_type_info[5] = { | |
| 194 | + { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 }, | |
| 195 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 }, | |
| 196 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 }, | |
| 197 | + { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 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]={ | |
| 200 | −{MB_TYPE_16x16|MB_TYPE_P0L0 , 1}, | |
| 201 | −{MB_TYPE_16x8 |MB_TYPE_P0L0 , 2}, | |
| 202 | −{MB_TYPE_8x16 |MB_TYPE_P0L0 , 2}, | |
| 203 | −{MB_TYPE_8x8 |MB_TYPE_P0L0 , 4}, | |
| 201 | +static const PMbInfo p_sub_mb_type_info[4] = { | |
| 202 | + { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 }, | |
| 203 | + { MB_TYPE_16x8 | MB_TYPE_P0L0, 2 }, | |
| 204 | + { MB_TYPE_8x16 | MB_TYPE_P0L0, 2 }, | |
| 205 | + { MB_TYPE_8x8 | MB_TYPE_P0L0, 4 }, | |
| 204 | 206 | }; |
| 205 | 207 | |
| 206 | −static const PMbInfo b_mb_type_info[23]={ | |
| 207 | −{MB_TYPE_DIRECT2|MB_TYPE_L0L1 , 1, }, | |
| 208 | −{MB_TYPE_16x16|MB_TYPE_P0L0 , 1, }, | |
| 209 | −{MB_TYPE_16x16 |MB_TYPE_P0L1 , 1, }, | |
| 210 | −{MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1 , 1, }, | |
| 211 | −{MB_TYPE_16x8 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 2, }, | |
| 212 | −{MB_TYPE_8x16 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 2, }, | |
| 213 | −{MB_TYPE_16x8 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | |
| 214 | −{MB_TYPE_8x16 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | |
| 215 | −{MB_TYPE_16x8 |MB_TYPE_P0L0 |MB_TYPE_P1L1, 2, }, | |
| 216 | −{MB_TYPE_8x16 |MB_TYPE_P0L0 |MB_TYPE_P1L1, 2, }, | |
| 217 | −{MB_TYPE_16x8 |MB_TYPE_P0L1|MB_TYPE_P1L0 , 2, }, | |
| 218 | −{MB_TYPE_8x16 |MB_TYPE_P0L1|MB_TYPE_P1L0 , 2, }, | |
| 219 | −{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, }, | |
| 221 | −{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, }, | |
| 223 | −{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, }, | |
| 225 | −{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, }, | |
| 227 | −{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, }, | |
| 229 | −{MB_TYPE_8x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 4, }, | |
| 208 | +static const PMbInfo b_mb_type_info[23] = { | |
| 209 | + { MB_TYPE_DIRECT2 | MB_TYPE_L0L1, 1, }, | |
| 210 | + { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, }, | |
| 211 | + { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, }, | |
| 212 | + { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, }, | |
| 213 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, }, | |
| 214 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, }, | |
| 215 | + { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, | |
| 216 | + { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, | |
| 217 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, }, | |
| 218 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, }, | |
| 219 | + { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, }, | |
| 220 | + { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, }, | |
| 221 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, | |
| 222 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, | |
| 223 | + { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, | |
| 224 | + { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, | |
| 225 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, }, | |
| 226 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, }, | |
| 227 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, | |
| 228 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, | |
| 229 | + { MB_TYPE_16x8 | 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, }, | |
| 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]={ | |
| 233 | −{MB_TYPE_DIRECT2 , 1, }, | |
| 234 | −{MB_TYPE_16x16|MB_TYPE_P0L0 , 1, }, | |
| 235 | −{MB_TYPE_16x16 |MB_TYPE_P0L1 , 1, }, | |
| 236 | −{MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1 , 1, }, | |
| 237 | −{MB_TYPE_16x8 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 2, }, | |
| 238 | −{MB_TYPE_8x16 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 2, }, | |
| 239 | −{MB_TYPE_16x8 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | |
| 240 | −{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, }, | |
| 242 | −{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, }, | |
| 244 | −{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, }, | |
| 234 | +static const PMbInfo b_sub_mb_type_info[13] = { | |
| 235 | + { MB_TYPE_DIRECT2, 1, }, | |
| 236 | + { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, }, | |
| 237 | + { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, }, | |
| 238 | + { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, }, | |
| 239 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, }, | |
| 240 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, }, | |
| 241 | + { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, | |
| 242 | + { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, | |
| 243 | + { MB_TYPE_16x8 | 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, }, | |
| 245 | + { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4, }, | |
| 246 | + { MB_TYPE_8x8 | MB_TYPE_P0L1 | 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]={ | |
| 249 | − {10,13,16}, | |
| 250 | − {11,14,18}, | |
| 251 | − {13,16,20}, | |
| 252 | − {14,18,23}, | |
| 253 | − {16,20,25}, | |
| 254 | − {18,23,29}, | |
| 250 | +static const uint8_t dequant4_coeff_init[6][3] = { | |
| 251 | + { 10, 13, 16 }, | |
| 252 | + { 11, 14, 18 }, | |
| 253 | + { 13, 16, 20 }, | |
| 254 | + { 14, 18, 23 }, | |
| 255 | + { 16, 20, 25 }, | |
| 256 | + { 18, 23, 29 }, | |
| 255 | 257 | }; |
| 256 | 258 | |
| 257 | 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]={ | |
| 261 | − {20,18,32,19,25,24}, | |
| 262 | − {22,19,35,21,28,26}, | |
| 263 | − {26,23,42,24,33,31}, | |
| 264 | − {28,25,45,26,35,33}, | |
| 265 | − {32,28,51,30,40,38}, | |
| 266 | − {36,32,58,34,46,43}, | |
| 262 | + | |
| 263 | +static const uint8_t dequant8_coeff_init[6][6] = { | |
| 264 | + { 20, 18, 32, 19, 25, 24 }, | |
| 265 | + { 22, 19, 35, 21, 28, 26 }, | |
| 266 | + { 26, 23, 42, 24, 33, 31 }, | |
| 267 | + { 28, 25, 45, 26, 35, 33 }, | |
| 268 | + { 32, 28, 51, 30, 40, 38 }, | |
| 269 | + { 36, 32, 58, 34, 46, 43 }, | |
| 267 | 270 | }; |
| 268 | 271 | |
| 269 | 272 | #endif /* AVCODEC_H264DATA_H */ |
| @@ -28,56 +28,90 @@ · 27 unmodified lines | ||
| 28 | 28 | #define AVCODEC_H264DSP_H |
| 29 | 29 | |
| 30 | 30 | #include <stdint.h> |
| 31 | + | |
| 31 | 32 | #include "dsputil.h" |
| 32 | 33 | |
| 33 | 34 | typedef void (*h264_weight_func)(uint8_t *block, int stride, int height, |
| 34 | 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 | − int log2_denom, int weightd, int weights, int offset); | |
| 36 | +typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, | |
| 37 | + int stride, int height, int log2_denom, | |
| 38 | + int weightd, int weights, int offset); | |
| 37 | 39 | |
| 38 | 40 | /** |
| 39 | 41 | * Context for storing H.264 DSP functions |
| 40 | 42 | */ |
| 41 | −typedef struct H264DSPContext{ | |
| 43 | +typedef struct H264DSPContext { | |
| 42 | 44 | /* weighted MC */ |
| 43 | 45 | h264_weight_func weight_h264_pixels_tab[4]; |
| 44 | 46 | h264_biweight_func biweight_h264_pixels_tab[4]; |
| 45 | 47 | |
| 46 | 48 | /* loop filter */ |
| 47 | − void (*h264_v_loop_filter_luma)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta, int8_t *tc0); | |
| 48 | − void (*h264_h_loop_filter_luma)(uint8_t *pix/*align 4 */, int stride, 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); | |
| 49 | + void (*h264_v_loop_filter_luma)(uint8_t *pix /*align 16*/, int stride, | |
| 50 | + 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 | 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); | |
| 52 | − void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta); | |
| 53 | − void (*h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta); | |
| 54 | − void (*h264_v_loop_filter_chroma)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta, int8_t *tc0); | |
| 55 | − void (*h264_h_loop_filter_chroma)(uint8_t *pix/*align 4*/, int stride, int alpha, int beta, int8_t *tc0); | |
| 56 | − void (*h264_h_loop_filter_chroma_mbaff)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta, int8_t *tc0); | |
| 57 | − void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta); | |
| 58 | − void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta); | |
| 59 | − void (*h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta); | |
| 56 | + void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride, | |
| 57 | + int alpha, int beta); | |
| 58 | + void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride, | |
| 59 | + int alpha, int beta); | |
| 60 | + void (*h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix /*align 16*/, | |
| 61 | + int stride, int alpha, int beta); | |
| 62 | + void (*h264_v_loop_filter_chroma)(uint8_t *pix /*align 8*/, int stride, | |
| 63 | + int alpha, int beta, int8_t *tc0); | |
| 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 | 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], | |
| 62 | − int bidir, int edges, int step, int mask_mv0, int mask_mv1, int field); | |
| 76 | + void (*h264_loop_filter_strength)(int16_t bS[2][4][4], uint8_t nnz[40], | |
| 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 | 81 | /* IDCT */ |
| 65 | − void (*h264_idct_add)(uint8_t *dst/*align 4*/, DCTELEM *block/*align 16*/, int stride); | |
| 66 | − void (*h264_idct8_add)(uint8_t *dst/*align 8*/, DCTELEM *block/*align 16*/, int stride); | |
| 67 | − void (*h264_idct_dc_add)(uint8_t *dst/*align 4*/, DCTELEM *block/*align 16*/, int stride); | |
| 68 | − void (*h264_idct8_dc_add)(uint8_t *dst/*align 8*/, DCTELEM *block/*align 16*/, int stride); | |
| 82 | + void (*h264_idct_add)(uint8_t *dst /*align 4*/, | |
| 83 | + DCTELEM *block /*align 16*/, int stride); | |
| 84 | + void (*h264_idct8_add)(uint8_t *dst /*align 8*/, | |
| 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]); | |
| 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]); | |
| 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]); | |
| 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]); | |
| 74 | − void (*h264_luma_dc_dequant_idct)(DCTELEM *output, DCTELEM *input/*align 16*/, int qmul); | |
| 91 | + void (*h264_idct_add16)(uint8_t *dst /*align 16*/, const int *blockoffset, | |
| 92 | + DCTELEM *block /*align 16*/, int stride, | |
| 93 | + const uint8_t nnzc[15 * 8]); | |
| 94 | + void (*h264_idct8_add4)(uint8_t *dst /*align 16*/, const int *blockoffset, | |
| 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 | 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); | |
| 79 | −void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); | |
| 80 | −void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); | |
| 81 | −void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); | |
| 108 | +void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, | |
| 109 | + const int chroma_format_idc); | |
| 110 | +void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, | |
| 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 | 117 | #endif /* AVCODEC_H264DSP_H */ |
| @@ -35,18 +35,18 @@ · 34 unmodified lines | ||
| 35 | 35 | * Prediction types |
| 36 | 36 | */ |
| 37 | 37 | //@{ |
| 38 | −#define VERT_PRED 0 | |
| 39 | −#define HOR_PRED 1 | |
| 40 | −#define DC_PRED 2 | |
| 41 | −#define DIAG_DOWN_LEFT_PRED 3 | |
| 42 | −#define DIAG_DOWN_RIGHT_PRED 4 | |
| 43 | −#define VERT_RIGHT_PRED 5 | |
| 44 | −#define HOR_DOWN_PRED 6 | |
| 45 | −#define VERT_LEFT_PRED 7 | |
| 46 | −#define HOR_UP_PRED 8 | |
| 38 | +#define VERT_PRED 0 | |
| 39 | +#define HOR_PRED 1 | |
| 40 | +#define DC_PRED 2 | |
| 41 | +#define DIAG_DOWN_LEFT_PRED 3 | |
| 42 | +#define DIAG_DOWN_RIGHT_PRED 4 | |
| 43 | +#define VERT_RIGHT_PRED 5 | |
| 44 | +#define HOR_DOWN_PRED 6 | |
| 45 | +#define VERT_LEFT_PRED 7 | |
| 46 | +#define HOR_UP_PRED 8 | |
| 47 | 47 | |
| 48 | 48 | // DC edge (not for VP8) |
| 49 | −#define LEFT_DC_PRED 9 | |
| 49 | +#define LEFT_DC_PRED 9 | |
| 50 | 50 | #define TOP_DC_PRED 10 |
| 51 | 51 | #define DC_128_PRED 11 |
| 52 | 52 | |
| @@ -56,7 +56,7 @@ · 3 unmodified lines | ||
| 56 | 56 | #define VERT_LEFT_PRED_RV40_NODOWN 14 |
| 57 | 57 | |
| 58 | 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 | 60 | #define VERT_VP8_PRED 10 ///< for VP8, #VERT_PRED is the average of |
| 61 | 61 | ///< (left col+cur col x2+right col) / 4; |
| 62 | 62 | ///< this is the "unaveraged" one |
| @@ -65,44 +65,53 @@ · 2 unmodified lines | ||
| 65 | 65 | #define DC_127_PRED 12 |
| 66 | 66 | #define DC_129_PRED 13 |
| 67 | 67 | |
| 68 | −#define DC_PRED8x8 0 | |
| 69 | −#define HOR_PRED8x8 1 | |
| 70 | −#define VERT_PRED8x8 2 | |
| 71 | −#define PLANE_PRED8x8 3 | |
| 68 | +#define DC_PRED8x8 0 | |
| 69 | +#define HOR_PRED8x8 1 | |
| 70 | +#define VERT_PRED8x8 2 | |
| 71 | +#define PLANE_PRED8x8 3 | |
| 72 | 72 | |
| 73 | 73 | // DC edge |
| 74 | −#define LEFT_DC_PRED8x8 4 | |
| 75 | −#define TOP_DC_PRED8x8 5 | |
| 76 | −#define DC_128_PRED8x8 6 | |
| 74 | +#define LEFT_DC_PRED8x8 4 | |
| 75 | +#define TOP_DC_PRED8x8 5 | |
| 76 | +#define DC_128_PRED8x8 6 | |
| 77 | 77 | |
| 78 | 78 | // H264/SVQ3 (8x8) specific |
| 79 | −#define ALZHEIMER_DC_L0T_PRED8x8 7 | |
| 80 | −#define ALZHEIMER_DC_0LT_PRED8x8 8 | |
| 81 | −#define ALZHEIMER_DC_L00_PRED8x8 9 | |
| 79 | +#define ALZHEIMER_DC_L0T_PRED8x8 7 | |
| 80 | +#define ALZHEIMER_DC_0LT_PRED8x8 8 | |
| 81 | +#define ALZHEIMER_DC_L00_PRED8x8 9 | |
| 82 | 82 | #define ALZHEIMER_DC_0L0_PRED8x8 10 |
| 83 | 83 | |
| 84 | 84 | // VP8 specific |
| 85 | −#define DC_127_PRED8x8 7 | |
| 86 | −#define DC_129_PRED8x8 8 | |
| 85 | +#define DC_127_PRED8x8 7 | |
| 86 | +#define DC_129_PRED8x8 8 | |
| 87 | 87 | //@} |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * Context for storing H.264 prediction functions |
| 91 | 91 | */ |
| 92 | −typedef struct H264PredContext{ | |
| 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); | |
| 95 | − void (*pred8x8 [4+3+4])(uint8_t *src, int stride); | |
| 96 | − void (*pred16x16[4+3+2])(uint8_t *src, int stride); | |
| 92 | +typedef struct H264PredContext { | |
| 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); | |
| 95 | + void(*pred8x8[4 + 3 + 4])(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); | |
| 99 | − void (*pred8x8l_add [2])(uint8_t *pix/*align 8*/, 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); | |
| 101 | − void (*pred16x16_add[3])(uint8_t *pix/*align 16*/, const int *block_offset, const DCTELEM *block/*align 16*/, int stride); | |
| 102 | −}H264PredContext; | |
| 98 | + void(*pred4x4_add[2])(uint8_t *pix /*align 4*/, | |
| 99 | + const DCTELEM *block /*align 16*/, int stride); | |
| 100 | + void(*pred8x8l_add[2])(uint8_t *pix /*align 8*/, | |
| 101 | + const DCTELEM *block /*align 16*/, int stride); | |
| 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); | |
| 105 | −void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, 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); | |
| 110 | +void ff_h264_pred_init(H264PredContext *h, int codec_id, | |
| 111 | + 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 | 117 | #endif /* AVCODEC_H264PRED_H */ |
| @@ -21,39 +21,57 @@ · 20 unmodified lines | ||
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * @file |
| 24 | − * ati vcr1 codec. | |
| 24 | + * ATI VCR1 codec | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #include "avcodec.h" |
| 28 | 28 | #include "dsputil.h" |
| 29 | 29 | |
| 30 | −//#undef NDEBUG | |
| 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; | |
| 30 | +typedef struct VCR1Context { | |
| 39 | 31 | AVFrame picture; |
| 40 | 32 | int delta[16]; |
| 41 | 33 | int offset[4]; |
| 42 | 34 | } VCR1Context; |
| 43 | 35 | |
| 44 | −static int decode_frame(AVCodecContext *avctx, | |
| 45 | − void *data, int *data_size, | |
| 46 | − AVPacket *avpkt) | |
| 36 | +static av_cold void common_init(AVCodecContext *avctx) | |
| 37 | +{ | |
| 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; | |
| 49 | − int buf_size = avpkt->size; | |
| 50 | − VCR1Context * const a = avctx->priv_data; | |
| 51 | − AVFrame *picture = data; | |
| 52 | − AVFrame * const p = &a->picture; | |
| 53 | − const uint8_t *bytestream= buf; | |
| 66 | + const uint8_t *buf = avpkt->data; | |
| 67 | + int buf_size = avpkt->size; | |
| 68 | + VCR1Context *const a = avctx->priv_data; | |
| 69 | + AVFrame *picture = data; | |
| 70 | + AVFrame *const p = &a->picture; | |
| 71 | + const uint8_t *bytestream = buf; | |
| 54 | 72 | int i, x, y; |
| 55 | 73 | |
| 56 | − if(p->data[0]) | |
| 74 | + if (p->data[0]) | |
| 57 | 75 | avctx->release_buffer(avctx, p); |
| 58 | 76 | |
| 59 | 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 | 79 | return AVERROR(EINVAL); |
| 62 | 80 | } |
| 63 | 81 | |
| 64 | − p->reference= 0; | |
| 65 | − if(avctx->get_buffer(avctx, p) < 0){ | |
| 82 | + p->reference = 0; | |
| 83 | + if (avctx->get_buffer(avctx, p) < 0) { | |
| 66 | 84 | av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
| 67 | 85 | return -1; |
| 68 | 86 | } |
| 69 | − p->pict_type= AV_PICTURE_TYPE_I; | |
| 70 | − p->key_frame= 1; | |
| 87 | + p->pict_type = AV_PICTURE_TYPE_I; | |
| 88 | + p->key_frame = 1; | |
| 71 | 89 | |
| 72 | − for(i=0; i<16; i++){ | |
| 73 | − a->delta[i]= *(bytestream++); | |
| 90 | + for (i = 0; i < 16; i++) { | |
| 91 | + a->delta[i] = *bytestream++; | |
| 74 | 92 | bytestream++; |
| 75 | 93 | } |
| 76 | 94 | |
| 77 | − for(y=0; y<avctx->height; y++){ | |
| 95 | + for (y = 0; y < avctx->height; y++) { | |
| 78 | 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){ | |
| 82 | − 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] ]; | |
| 99 | + if ((y & 3) == 0) { | |
| 100 | + uint8_t *cb = &a->picture.data[1][(y >> 2) * a->picture.linesize[1]]; | |
| 101 | + uint8_t *cr = &a->picture.data[2][(y >> 2) * a->picture.linesize[2]]; | |
| 84 | 102 | |
| 85 | − for(i=0; i<4; i++) | |
| 86 | − a->offset[i]= *(bytestream++); | |
| 103 | + for (i = 0; i < 4; i++) | |
| 104 | + a->offset[i] = *bytestream++; | |
| 87 | 105 | |
| 88 | − offset= a->offset[0] - a->delta[ bytestream[2]&0xF ]; | |
| 89 | − for(x=0; x<avctx->width; x+=4){ | |
| 90 | − luma[0]=( offset += a->delta[ bytestream[2]&0xF ]); | |
| 91 | − luma[1]=( offset += a->delta[ bytestream[2]>>4 ]); | |
| 92 | − luma[2]=( offset += a->delta[ bytestream[0]&0xF ]); | |
| 93 | − luma[3]=( offset += a->delta[ bytestream[0]>>4 ]); | |
| 94 | − luma += 4; | |
| 106 | + offset = a->offset[0] - a->delta[bytestream[2] & 0xF]; | |
| 107 | + for (x = 0; x < avctx->width; x += 4) { | |
| 108 | + luma[0] = offset += a->delta[bytestream[2] & 0xF]; | |
| 109 | + luma[1] = offset += a->delta[bytestream[2] >> 4]; | |
| 110 | + luma[2] = offset += a->delta[bytestream[0] & 0xF]; | |
| 111 | + luma[3] = offset += a->delta[bytestream[0] >> 4]; | |
| 112 | + luma += 4; | |
| 95 | 113 | |
| 96 | − *(cb++) = bytestream[3]; | |
| 97 | − *(cr++) = bytestream[1]; | |
| 114 | + *cb++ = bytestream[3]; | |
| 115 | + *cr++ = bytestream[1]; | |
| 98 | 116 | |
| 99 | − bytestream+= 4; | |
| 117 | + bytestream += 4; | |
| 100 | 118 | } |
| 101 | − }else{ | |
| 102 | − offset= a->offset[y&3] - a->delta[ bytestream[2]&0xF ]; | |
| 103 | − | |
| 104 | − for(x=0; x<avctx->width; x+=8){ | |
| 105 | − luma[0]=( offset += a->delta[ bytestream[2]&0xF ]); | |
| 106 | − luma[1]=( offset += a->delta[ bytestream[2]>>4 ]); | |
| 107 | − luma[2]=( offset += a->delta[ bytestream[3]&0xF ]); | |
| 108 | − luma[3]=( offset += a->delta[ bytestream[3]>>4 ]); | |
| 109 | − luma[4]=( offset += a->delta[ bytestream[0]&0xF ]); | |
| 110 | − luma[5]=( offset += a->delta[ bytestream[0]>>4 ]); | |
| 111 | − luma[6]=( offset += a->delta[ bytestream[1]&0xF ]); | |
| 112 | − luma[7]=( offset += a->delta[ bytestream[1]>>4 ]); | |
| 113 | − luma += 8; | |
| 114 | − bytestream+= 4; | |
| 119 | + } else { | |
| 120 | + offset = a->offset[y & 3] - a->delta[bytestream[2] & 0xF]; | |
| 121 | + | |
| 122 | + for (x = 0; x < avctx->width; x += 8) { | |
| 123 | + luma[0] = offset += a->delta[bytestream[2] & 0xF]; | |
| 124 | + luma[1] = offset += a->delta[bytestream[2] >> 4]; | |
| 125 | + luma[2] = offset += a->delta[bytestream[3] & 0xF]; | |
| 126 | + luma[3] = offset += a->delta[bytestream[3] >> 4]; | |
| 127 | + luma[4] = offset += a->delta[bytestream[0] & 0xF]; | |
| 128 | + luma[5] = offset += a->delta[bytestream[0] >> 4]; | |
| 129 | + luma[6] = offset += a->delta[bytestream[1] & 0xF]; | |
| 130 | + luma[7] = offset += a->delta[bytestream[1] >> 4]; | |
| 131 | + luma += 8; | |
| 132 | + bytestream += 4; | |
| 115 | 133 | } |
| 116 | 134 | } |
| 117 | 135 | } |
| @@ -122,62 +140,6 @@ static int decode_frame(AVCodecContext *avctx, · 4 unmodified lines | ||
| 122 | 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 | 143 | AVCodec ff_vcr1_decoder = { |
| 182 | 144 | .name = "vcr1", |
| 183 | 145 | .type = AVMEDIA_TYPE_VIDEO, |
| @@ -190,14 +152,39 @@ AVCodec ff_vcr1_decoder = { · 6 unmodified lines | ||
| 190 | 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 | 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 | 181 | AVCodec ff_vcr1_encoder = { |
| 195 | 182 | .name = "vcr1", |
| 196 | 183 | .type = AVMEDIA_TYPE_VIDEO, |
| 197 | 184 | .id = CODEC_ID_VCR1, |
| 198 | 185 | .priv_data_size = sizeof(VCR1Context), |
| 199 | − .init = encode_init, | |
| 186 | + .init = common_init, | |
| 200 | 187 | .encode = encode_frame, |
| 201 | 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 | 1792 | QPEL_2TAP(put_, 8, 3dnow) |
| 1793 | 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 | 1812 | #if HAVE_YASM |
| 1797 | 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 | 199 | void ff_put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd); |
| 200 | 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 | 207 | void ff_mmx_idct(DCTELEM *block); |
| 203 | 208 | void ff_mmxext_idct(DCTELEM *block); |
| 204 | 209 | |
| @@ -1,5 +1,7 @@ | ||
| 1 | 1 | ;****************************************************************************** |
| 2 | 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 | 5 | ;* Copyright (C) 2012 Christophe Gisquet <christophe.gisquet@gmail.com> |
| 4 | 6 | ;* |
| 5 | 7 | ;* This file is part of Libav. |
| @@ -25,11 +27,319 @@ · 19 unmodified lines | ||
| 25 | 27 | SECTION_RODATA |
| 26 | 28 | |
| 27 | 29 | align 16 |
| 28 | −shift_round: times 8 dw 1 << (16 - 6) | |
| 29 | −cextern pw_16 | |
| 30 | +pw_1024: times 8 dw 1 << (16 - 6) ; pw_1024 | |
| 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 | 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 | 343 | ; %1=5bits weights?, %2=dst %3=src1 %4=src3 %5=stride if sse2 |
| 34 | 344 | %macro RV40_WCORE 4-5 |
| 35 | 345 | movh m4, [%3 + r6 + 0] |
| @@ -143,7 +453,7 @@ SECTION .text · 107 unmodified lines | ||
| 143 | 453 | %macro RV40_WEIGHT 3 |
| 144 | 454 | cglobal rv40_weight_func_%1_%2, 6, 7, 8 |
| 145 | 455 | %if cpuflag(ssse3) |
| 146 | − mova m1, [shift_round] | |
| 456 | + mova m1, [pw_1024] | |
| 147 | 457 | %else |
| 148 | 458 | mova m1, [pw_16] |
| 149 | 459 | %endif |
| @@ -22,8 +22,11 @@ · 21 unmodified lines | ||
| 22 | 22 | /** |
| 23 | 23 | * @file |
| 24 | 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 | 30 | #include "libavcodec/rv34dsp.h" |
| 28 | 31 | |
| 29 | 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 | 56 | DECLARE_WEIGHT(sse2) |
| 54 | 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 | 185 | void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp) |
| 57 | 186 | { |
| 58 | 187 | #if HAVE_YASM |
| @@ -65,25 +194,42 @@ void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp) · 6 unmodified lines | ||
| 65 | 194 | c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_mmx; |
| 66 | 195 | c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_mmx; |
| 67 | 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 | 205 | if (mm_flags & AV_CPU_FLAG_MMX2) { |
| 70 | 206 | c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_mmx2; |
| 71 | 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 | 211 | } else if (mm_flags & AV_CPU_FLAG_3DNOW) { |
| 73 | 212 | c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_3dnow; |
| 74 | 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 | 218 | if (mm_flags & AV_CPU_FLAG_SSE2) { |
| 77 | 219 | c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_sse2; |
| 78 | 220 | c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_sse2; |
| 79 | 221 | c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_sse2; |
| 80 | 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 | 226 | if (mm_flags & AV_CPU_FLAG_SSSE3) { |
| 83 | 227 | c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_ssse3; |
| 84 | 228 | c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_ssse3; |
| 85 | 229 | c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_ssse3; |
| 86 | 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 | 234 | #endif |
| 89 | 235 | } |
| @@ -21,6 +21,7 @@ HEADERS = asrc_abuffer.h \ · 20 unmodified lines | ||
| 21 | 21 | vsrc_buffer.h \ |
| 22 | 22 | |
| 23 | 23 | OBJS = allfilters.o \ |
| 24 | + audio.o \ | |
| 24 | 25 | avfilter.o \ |
| 25 | 26 | avfiltergraph.o \ |
| 26 | 27 | buffersink.o \ |
| @@ -144,7 +144,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 143 unmodified lines | ||
| 144 | 144 | AConvertContext *aconvert = inlink->dst->priv; |
| 145 | 145 | const int n = insamplesref->audio->nb_samples; |
| 146 | 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 | 149 | swr_convert(aconvert->swr, outsamplesref->data, n, |
| 150 | 150 | (void *)insamplesref->data, n); |
| @@ -153,7 +153,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 2 unmodified lines | ||
| 153 | 153 | outsamplesref->audio->channel_layout = outlink->channel_layout; |
| 154 | 154 | outsamplesref->audio->planar = outlink->planar; |
| 155 | 155 | |
| 156 | − avfilter_filter_samples(outlink, outsamplesref); | |
| 156 | + ff_filter_samples(outlink, outsamplesref); | |
| 157 | 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 | 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 | 95 | AVFilter avfilter_af_aformat = { |
| @@ -208,7 +208,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 207 unmodified lines | ||
| 208 | 208 | |
| 209 | 209 | nb_samples = FFMIN(am->queue[0].nb_samples, |
| 210 | 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 | 212 | nb_samples); |
| 213 | 213 | outs = outbuf->data[0]; |
| 214 | 214 | for (i = 0; i < 2; i++) { |
| @@ -264,7 +264,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 49 unmodified lines | ||
| 264 | 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 | 270 | AVFilter avfilter_af_amerge = { |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | * null audio filter |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | +#include "audio.h" | |
| 24 | 25 | #include "avfilter.h" |
| 25 | 26 | |
| 26 | 27 | AVFilter avfilter_af_anull = { |
| @@ -31,8 +32,8 @@ AVFilter avfilter_af_anull = { · 4 unmodified lines | ||
| 31 | 32 | |
| 32 | 33 | .inputs = (const AVFilterPad[]) {{ .name = "default", |
| 33 | 34 | .type = AVMEDIA_TYPE_AUDIO, |
| 34 | − .get_audio_buffer = avfilter_null_get_audio_buffer, | |
| 35 | − .filter_samples = avfilter_null_filter_samples }, | |
| 35 | + .get_audio_buffer = ff_null_get_audio_buffer, | |
| 36 | + .filter_samples = ff_null_filter_samples }, | |
| 36 | 37 | { .name = NULL}}, |
| 37 | 38 | |
| 38 | 39 | .outputs = (const AVFilterPad[]) {{ .name = "default", |
| @@ -92,7 +92,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 91 unmodified lines | ||
| 92 | 92 | const int n_in = insamplesref->audio->nb_samples; |
| 93 | 93 | int n_out = n_in * aresample->ratio; |
| 94 | 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 | 97 | n_out = swr_convert(aresample->swr, outsamplesref->data, n_out, |
| 98 | 98 | (void *)insamplesref->data, n_in); |
| @@ -103,7 +103,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 4 unmodified lines | ||
| 103 | 103 | outsamplesref->pts = insamplesref->pts == AV_NOPTS_VALUE ? AV_NOPTS_VALUE : |
| 104 | 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 | 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 | 83 | av_log(ctx, AV_LOG_INFO, "]\n"); |
| 84 | 84 | |
| 85 | 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 | 89 | AVFilter avfilter_af_ashowinfo = { |
| @@ -95,7 +95,7 @@ AVFilter avfilter_af_ashowinfo = { · 5 unmodified lines | ||
| 95 | 95 | |
| 96 | 96 | .inputs = (const AVFilterPad[]) {{ .name = "default", |
| 97 | 97 | .type = AVMEDIA_TYPE_AUDIO, |
| 98 | − .get_audio_buffer = avfilter_null_get_audio_buffer, | |
| 98 | + .get_audio_buffer = ff_null_get_audio_buffer, | |
| 99 | 99 | .filter_samples = filter_samples, |
| 100 | 100 | .min_perms = AV_PERM_READ, }, |
| 101 | 101 | { .name = NULL}}, |
| @@ -27,9 +27,9 @@ · 26 unmodified lines | ||
| 27 | 27 | |
| 28 | 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 | 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 | 33 | avfilter_ref_buffer(insamples, ~AV_PERM_WRITE)); |
| 34 | 34 | avfilter_unref_buffer(insamples); |
| 35 | 35 | } |
| @@ -41,7 +41,7 @@ AVFilter avfilter_af_asplit = { · 5 unmodified lines | ||
| 41 | 41 | .inputs = (const AVFilterPad[]) { |
| 42 | 42 | { .name = "default", |
| 43 | 43 | .type = AVMEDIA_TYPE_AUDIO, |
| 44 | − .get_audio_buffer = avfilter_null_get_audio_buffer, | |
| 44 | + .get_audio_buffer = ff_null_get_audio_buffer, | |
| 45 | 45 | .filter_samples = filter_samples, }, |
| 46 | 46 | { .name = NULL} |
| 47 | 47 | }, |
| @@ -119,7 +119,7 @@ static void send_out(AVFilterContext *ctx, int out_id) · 118 unmodified lines | ||
| 119 | 119 | av_q2d(ctx->outputs[out_id]->time_base) * buf->pts; |
| 120 | 120 | as->var_values[VAR_T1 + out_id] += buf->audio->nb_samples / |
| 121 | 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 | 123 | queue->nb--; |
| 124 | 124 | queue->tail = (queue->tail + 1) % QUEUE_SIZE; |
| 125 | 125 | if (as->req[out_id]) |
| @@ -122,7 +122,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 121 unmodified lines | ||
| 122 | 122 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 123 | 123 | int16_t *taps, *endin, *in, *out; |
| 124 | 124 | AVFilterBufferRef *outsamples = |
| 125 | − avfilter_get_audio_buffer(inlink, AV_PERM_WRITE, | |
| 125 | + ff_get_audio_buffer(inlink, AV_PERM_WRITE, | |
| 126 | 126 | insamples->audio->nb_samples); |
| 127 | 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 | 141 | // save part of input for next round |
| 142 | 142 | memcpy(taps, endin, NUMTAPS * sizeof(*taps)); |
| 143 | 143 | |
| 144 | − avfilter_filter_samples(outlink, outsamples); | |
| 144 | + ff_filter_samples(outlink, outsamples); | |
| 145 | 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 | 341 | int n = insamples->audio->nb_samples; |
| 342 | 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 | 344 | PanContext *pan = inlink->dst->priv; |
| 345 | 345 | |
| 346 | 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 | 348 | outsamples->audio->channel_layout = outlink->channel_layout; |
| 349 | 349 | outsamples->audio->planar = outlink->planar; |
| 350 | 350 | |
| 351 | − avfilter_filter_samples(outlink, outsamples); | |
| 351 | + ff_filter_samples(outlink, outsamples); | |
| 352 | 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 | 129 | static int query_formats(AVFilterContext *ctx) |
| @@ -163,7 +163,7 @@ AVFilter avfilter_af_silencedetect = { · 33 unmodified lines | ||
| 163 | 163 | .inputs = (const AVFilterPad[]) { |
| 164 | 164 | { .name = "default", |
| 165 | 165 | .type = AVMEDIA_TYPE_AUDIO, |
| 166 | − .get_audio_buffer = avfilter_null_get_audio_buffer, | |
| 166 | + .get_audio_buffer = ff_null_get_audio_buffer, | |
| 167 | 167 | .filter_samples = filter_samples, }, |
| 168 | 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 | 173 | AVFilter avfilter_af_volume = { |
| @@ -205,7 +205,7 @@ static int request_frame(AVFilterLink *outlink) · 204 unmodified lines | ||
| 205 | 205 | if (eval->duration >= 0 && t > eval->duration) |
| 206 | 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 | 210 | /* evaluate expression for each single sample and for each channel */ |
| 211 | 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 | 223 | samplesref->audio->sample_rate = eval->sample_rate; |
| 224 | 224 | eval->pts += eval->nb_samples; |
| 225 | 225 | |
| 226 | − avfilter_filter_samples(outlink, samplesref); | |
| 226 | + ff_filter_samples(outlink, samplesref); | |
| 227 | 227 | |
| 228 | 228 | return 0; |
| 229 | 229 | } |
| @@ -108,13 +108,13 @@ static int request_frame(AVFilterLink *outlink) · 107 unmodified lines | ||
| 108 | 108 | AVFilterBufferRef *samplesref; |
| 109 | 109 | |
| 110 | 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 | 112 | samplesref->pts = null->pts; |
| 113 | 113 | samplesref->pos = -1; |
| 114 | 114 | samplesref->audio->channel_layout = null->channel_layout; |
| 115 | 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 | 118 | avfilter_unref_buffer(samplesref); |
| 119 | 119 | |
| 120 | 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 | 27 | #include "libavutil/imgutils.h" |
| 28 | 28 | #include "libavutil/avassert.h" |
| 29 | 29 | #include "libavutil/avstring.h" |
| 30 | + | |
| 30 | 31 | #include "avfilter.h" |
| 31 | 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 | 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 | 416 | if (link->type == AVMEDIA_TYPE_VIDEO) { |
| 416 | 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 | 438 | AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h) |
| 440 | 439 | { |
| 441 | 440 | AVFilterBufferRef *ret = NULL; |
| @@ -501,133 +500,6 @@ fail: · 59 unmodified lines | ||
| 501 | 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 | 503 | int avfilter_request_frame(AVFilterLink *link) |
| 632 | 504 | { |
| 633 | 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 | 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 | 534 | if (pts == AV_NOPTS_VALUE) |
| 663 | 535 | return; |
| @@ -706,7 +578,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 42 unmodified lines | ||
| 706 | 578 | } |
| 707 | 579 | |
| 708 | 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 | 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 | 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 | 653 | #define MAX_REGISTERED_AVFILTERS_NB 128 |
| 820 | 654 | |
| 821 | 655 | static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1]; |
| @@ -430,7 +430,8 @@ struct AVFilterPad { · 429 unmodified lines | ||
| 430 | 430 | * |
| 431 | 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 | 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 | 509 | /** default handler for end_frame() for video inputs */ |
| 509 | 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 | 512 | /** default handler for get_video_buffer() for video inputs */ |
| 515 | 513 | AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, |
| 516 | 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 | 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 | 536 | /** end_frame() handler for filters which simply pass video along */ |
| 542 | 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 | 539 | /** get_video_buffer() handler for filters which simply pass video along */ |
| 548 | 540 | AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, |
| 549 | 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 | 544 | * Filter definition. This defines the pads a filter contains, and all the |
| 557 | 545 | * callback functions used to interact with the filter. |
| @@ -665,7 +653,7 @@ struct AVFilterLink { · 107 unmodified lines | ||
| 665 | 653 | AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio |
| 666 | 654 | /* These parameters apply only to audio */ |
| 667 | 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 | 657 | int64_t sample_rate; ///< samples per second |
| 670 | 658 | #else |
| 671 | 659 | int sample_rate; ///< samples per second |
| @@ -790,19 +778,6 @@ AVFilterBufferRef * · 118 unmodified lines | ||
| 790 | 778 | avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms, |
| 791 | 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 | 782 | * Create an audio buffer reference wrapped around an already |
| 808 | 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 | 880 | int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags); |
| 906 | 881 | |
| 907 | −/** | |
| 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. */ | |
| 882 | +/** Initialize the filter system. Register all builtin filters. */ | |
| 918 | 883 | void avfilter_register_all(void); |
| 919 | 884 | |
| 920 | 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 | 989 | &f->output_pads, &f->outputs, p); |
| 1025 | 990 | } |
| 1026 | 991 | |
| 992 | +#include "audio.h" | |
| 993 | + | |
| 1027 | 994 | #endif /* AVFILTER_AVFILTER_H */ |
| @@ -23,6 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | #include "libavutil/audioconvert.h" |
| 24 | 24 | #include "libavutil/imgutils.h" |
| 25 | 25 | #include "libavutil/samplefmt.h" |
| 26 | + | |
| 26 | 27 | #include "avfilter.h" |
| 27 | 28 | #include "internal.h" |
| 28 | 29 | |
| @@ -87,38 +88,6 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per · 58 unmodified lines | ||
| 87 | 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 | 91 | void avfilter_default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
| 123 | 92 | { |
| 124 | 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 | 135 | static void set_common_formats(AVFilterContext *ctx, AVFilterFormats *fmts, |
| 188 | 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 | 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 | 209 | AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h) |
| 267 | 210 | { |
| 268 | 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 | 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 | 158 | #endif /* AVFILTER_INTERNAL_H */ |
| @@ -297,7 +297,7 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx, · 296 unmodified lines | ||
| 297 | 297 | break; |
| 298 | 298 | |
| 299 | 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 | 301 | ref->audio->nb_samples); |
| 302 | 302 | channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout); |
| 303 | 303 | data_size = av_samples_get_buffer_size(NULL, channels, |
| @@ -562,7 +562,7 @@ static int request_frame(AVFilterLink *link) · 258 unmodified lines | ||
| 562 | 562 | avfilter_unref_buffer(buf); |
| 563 | 563 | break; |
| 564 | 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 | 566 | avfilter_unref_buffer(buf); |
| 567 | 567 | break; |
| 568 | 568 | default: |
| @@ -437,7 +437,7 @@ static int amovie_get_samples(AVFilterLink *outlink) · 436 unmodified lines | ||
| 437 | 437 | if (data_size < 0) |
| 438 | 438 | return data_size; |
| 439 | 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 | 441 | memcpy(movie->samplesref->data[0], movie->frame->data[0], data_size); |
| 442 | 442 | movie->samplesref->pts = movie->pkt.pts; |
| 443 | 443 | movie->samplesref->pos = movie->pkt.pos; |
| @@ -463,7 +463,7 @@ static int amovie_request_frame(AVFilterLink *outlink) · 19 unmodified lines | ||
| 463 | 463 | return ret; |
| 464 | 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 | 467 | avfilter_unref_buffer(movie->samplesref); |
| 468 | 468 | movie->samplesref = NULL; |
| 469 | 469 | |
| @@ -47,5 +47,8 @@ · 46 unmodified lines | ||
| 47 | 47 | #ifndef FF_API_GRAPH_AVCLASS |
| 48 | 48 | #define FF_API_GRAPH_AVCLASS (LIBAVFILTER_VERSION_MAJOR > 2) |
| 49 | 49 | #endif |
| 50 | +#ifndef FF_API_SAMPLERATE64 | |
| 51 | +#define FF_API_SAMPLERATE64 (LIBAVFILTER_VERSION_MAJOR < 3) | |
| 52 | +#endif | |
| 50 | 53 | |
| 51 | 54 | #endif // AVFILTER_VERSION_H |
| @@ -1051,7 +1051,7 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 1050 unmodified lines | ||
| 1051 | 1051 | return AVERROR_INVALIDDATA; |
| 1052 | 1052 | |
| 1053 | 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 | 1055 | // wrap a whole fiel atom inside of a glbl atom. |
| 1056 | 1056 | unsigned size = avio_rb32(pb); |
| 1057 | 1057 | unsigned type = avio_rl32(pb); |
| @@ -44,6 +44,8 @@ · 43 unmodified lines | ||
| 44 | 44 | |
| 45 | 45 | #define APP_MAX_LENGTH 128 |
| 46 | 46 | #define PLAYPATH_MAX_LENGTH 256 |
| 47 | +#define TCURL_MAX_LENGTH 512 | |
| 48 | +#define FLASHVER_MAX_LENGTH 64 | |
| 47 | 49 | |
| 48 | 50 | /** RTMP protocol handler state */ |
| 49 | 51 | typedef enum { |
| @@ -82,6 +84,9 @@ typedef struct RTMPContext { · 32 unmodified lines | ||
| 82 | 84 | int flv_header_bytes; ///< number of initialized bytes in flv_header |
| 83 | 85 | int nb_invokes; ///< keeps track of invoke messages |
| 84 | 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 | 90 | } RTMPContext; |
| 86 | 91 | |
| 87 | 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 | 116 | * Generate 'connect' call and send it to the server. |
| 112 | 117 | */ |
| 113 | −static void gen_connect(URLContext *s, RTMPContext *rt, const char *proto, | |
| 114 | − const char *host, int port) | |
| 118 | +static void gen_connect(URLContext *s, RTMPContext *rt) | |
| 115 | 119 | { |
| 116 | 120 | RTMPPacket pkt; |
| 117 | − uint8_t ver[64], *p; | |
| 118 | − char tcurl[512]; | |
| 121 | + uint8_t *p; | |
| 119 | 122 | |
| 120 | 123 | ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 4096); |
| 121 | 124 | p = pkt.data; |
| 122 | 125 | |
| 123 | − ff_url_join(tcurl, sizeof(tcurl), proto, NULL, host, port, "/%s", rt->app); | |
| 124 | 126 | ff_amf_write_string(&p, "connect"); |
| 125 | 127 | ff_amf_write_number(&p, ++rt->nb_invokes); |
| 126 | 128 | ff_amf_write_object_start(&p); |
| 127 | 129 | ff_amf_write_field_name(&p, "app"); |
| 128 | 130 | ff_amf_write_string(&p, rt->app); |
| 129 | 131 | |
| 130 | − 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); | |
| 132 | + if (!rt->is_input) { | |
| 135 | 133 | ff_amf_write_field_name(&p, "type"); |
| 136 | 134 | ff_amf_write_string(&p, "nonprivate"); |
| 137 | 135 | } |
| 138 | 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 | 144 | ff_amf_write_field_name(&p, "tcUrl"); |
| 141 | − ff_amf_write_string(&p, tcurl); | |
| 145 | + ff_amf_write_string(&p, rt->tcurl); | |
| 142 | 146 | if (rt->is_input) { |
| 143 | 147 | ff_amf_write_field_name(&p, "fpad"); |
| 144 | 148 | ff_amf_write_bool(&p, 0); |
| @@ -368,6 +372,25 @@ static void gen_server_bw(URLContext *s, RTMPContext *rt) · 223 unmodified lines | ||
| 368 | 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 | 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 | 710 | if (!t && !strcmp(tmpstr, "NetStream.Play.Stop")) rt->state = STATE_STOPPED; |
| 688 | 711 | if (!t && !strcmp(tmpstr, "NetStream.Play.UnpublishNotify")) rt->state = STATE_STOPPED; |
| 689 | 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 | 716 | break; |
| 692 | 717 | } |
| @@ -910,13 +935,31 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) · 217 unmodified lines | ||
| 910 | 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 | 956 | rt->client_report_size = 1048576; |
| 914 | 957 | rt->bytes_read = 0; |
| 915 | 958 | rt->last_bytes_read = 0; |
| 916 | 959 | |
| 917 | 960 | av_log(s, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n", |
| 918 | 961 | proto, path, rt->app, rt->playpath); |
| 919 | − gen_connect(s, rt, proto, hostname, port); | |
| 962 | + gen_connect(s, rt); | |
| 920 | 963 | |
| 921 | 964 | do { |
| 922 | 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 | 1096 | static const AVOption rtmp_options[] = { |
| 1054 | 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 | 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 | 1100 | {"any", "both", 0, AV_OPT_TYPE_CONST, {-2}, 0, 0, DEC, "rtmp_live"}, |
| 1057 | 1101 | {"live", "live stream", 0, AV_OPT_TYPE_CONST, {-1}, 0, 0, DEC, "rtmp_live"}, |
| 1058 | 1102 | {"recorded", "recorded stream", 0, AV_OPT_TYPE_CONST, {0}, 0, 0, DEC, "rtmp_live"}, |
| 1059 | 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 | 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 | 227 | if (s->max_streams) { |
| 228 | 228 | initparams.sinit_max_instreams = s->max_streams; |
| 229 | 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 | 231 | sizeof(initparams)) < 0) |
| 232 | 232 | av_log(h, AV_LOG_ERROR, |
| 233 | 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 | 54 | mova m3, [srcq+src3q] |
| 55 | 55 | mova m4, [srcq+src4q] |
| 56 | 56 | mova m5, [srcq+src5q] |
| 57 | −%if cpuflag(sse) | |
| 57 | +%if cpuflag(sse4) | |
| 58 | 58 | SBUTTERFLYPS 0, 1, 6 |
| 59 | 59 | SBUTTERFLYPS 2, 3, 6 |
| 60 | 60 | SBUTTERFLYPS 4, 5, 6 |
| 61 | 61 | |
| 62 | − movaps m6, m4 | |
| 63 | − shufps m4, m0, q3210 | |
| 62 | + blendps m6, m4, m0, 1100b | |
| 64 | 63 | movlhps m0, m2 |
| 65 | − movhlps m6, m2 | |
| 66 | − movaps [dstq ], m0 | |
| 67 | − movaps [dstq+16], m4 | |
| 68 | − movaps [dstq+32], m6 | |
| 69 | − | |
| 70 | − movaps m6, m5 | |
| 71 | − shufps m5, m1, q3210 | |
| 64 | + movhlps m4, m2 | |
| 65 | + blendps m2, m5, m1, 1100b | |
| 72 | 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 | 72 | movaps [dstq+48], m1 |
| 75 | − movaps [dstq+64], m5 | |
| 76 | − movaps [dstq+80], m6 | |
| 73 | + movaps [dstq+64], m2 | |
| 74 | + movaps [dstq+80], m5 | |
| 77 | 75 | %else ; mmx |
| 78 | 76 | SBUTTERFLY dq, 0, 1, 6 |
| 79 | 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 | 99 | INIT_MMX mmx |
| 102 | 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 | 105 | CONV_FLTP_TO_FLT_6CH |
| 106 | +%endif | |
| @@ -22,8 +22,9 @@ · 21 unmodified lines | ||
| 22 | 22 | #include "libavutil/cpu.h" |
| 23 | 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); | |
| 26 | −extern void ff_conv_fltp_to_flt_6ch_sse(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_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 | 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 | 35 | ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, |
| 35 | 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 | 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 | 46 | #endif |
| 42 | 47 | } |
| @@ -42,10 +42,9 @@ · 41 unmodified lines | ||
| 42 | 42 | %endmacro |
| 43 | 43 | |
| 44 | 44 | %macro SBUTTERFLYPS 3 |
| 45 | − movaps m%3, m%1 | |
| 46 | − unpcklps m%1, m%2 | |
| 47 | − unpckhps m%3, m%2 | |
| 48 | − SWAP %2, %3 | |
| 45 | + unpcklps m%3, m%1, m%2 | |
| 46 | + unpckhps m%1, m%1, m%2 | |
| 47 | + SWAP %1, %3, %2 | |
| 49 | 48 | %endmacro |
| 50 | 49 | |
| 51 | 50 | %macro TRANSPOSE4x4B 5 |