History

Merge remote-tracking branch 'qatar/master'

* 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

Michael Niedermayer committed 14 years ago

Commit 01590322 parents 2a793ff 110d0cd44 files · +2256 −1429Browse files

Unified · Split

44 files
  1. cmdutils.c +2 −1
  2. configure +1 −1
  3. libavcodec/apedec.c +2 −2
  4. libavcodec/arm/dsputil_neon.S +92 −0
  5. libavcodec/h264.h +260 −236
  6. libavcodec/h264_mvpred.h +524 −481
  7. libavcodec/h264data.h +186 −183
  8. libavcodec/h264dsp.h +65 −31
  9. libavcodec/h264pred.h +45 −36
  10. libavcodec/vcr1.c +102 −115
  11. libavcodec/x86/dsputil_mmx.c +16 −0
  12. libavcodec/x86/dsputil_mmx.h +5 −0
  13. libavcodec/x86/rv40dsp.asm +313 −3
  14. libavcodec/x86/rv40dsp_init.c +146 −0
  15. libavfilter/Makefile +1 −0
  16. libavfilter/af_aconvert.c +2 −2
  17. libavfilter/af_aformat.c +1 −1
  18. libavfilter/af_amerge.c +2 −2
  19. libavfilter/af_anull.c +3 −2
  20. libavfilter/af_aresample.c +2 −2
  21. libavfilter/af_ashowinfo.c +2 −2
  22. libavfilter/af_asplit.c +3 −3
  23. libavfilter/af_astreamsync.c +1 −1
  24. libavfilter/af_earwax.c +2 −2
  25. libavfilter/af_pan.c +2 −2
  26. libavfilter/af_silencedetect.c +2 −2
  27. libavfilter/af_volume.c +1 −1
  28. libavfilter/asrc_aevalsrc.c +2 −2
  29. libavfilter/asrc_anullsrc.c +2 −2
  30. libavfilter/audio.c +291 −0
  31. libavfilter/audio.h +65 −0
  32. libavfilter/avfilter.c +4 −170
  33. libavfilter/avfilter.h +6 −39
  34. libavfilter/defaults.c +1 −64
  35. libavfilter/internal.h +6 −0
  36. libavfilter/src_buffer.c +2 −2
  37. libavfilter/src_movie.c +2 −2
  38. libavfilter/version.h +3 −0
  39. libavformat/mov.c +1 −1
  40. libavformat/rtmpproto.c +59 −13
  41. libavformat/sctp.c +1 −1
  42. libavresample/x86/audio_convert.asm +16 −14
  43. libavresample/x86/audio_convert_init.c +9 −4
  44. libavutil/x86/x86util.asm +3 −4
cmdutils.c+2−1
@@ -38,6 +38,7 @@ · 37 unmodified lines
3838 #if CONFIG_POSTPROC
3939 #include "libpostproc/postprocess.h"
4040 #endif
41+#include "libavutil/avassert.h"
4142 #include "libavutil/avstring.h"
4243 #include "libavutil/mathematics.h"
4344 #include "libavutil/parseutils.h"
@@ -1075,7 +1076,7 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) · 1031 unmodified lines
10751076 case 's': type = AVMEDIA_TYPE_SUBTITLE; break;
10761077 case 'd': type = AVMEDIA_TYPE_DATA; break;
10771078 case 't': type = AVMEDIA_TYPE_ATTACHMENT; break;
1078− default: abort(); // never reached, silence warning
1079+ default: av_assert0(0);
10791080 }
10801081 if (type != st->codec->codec_type)
10811082 return 0;
configure+1−1
@@ -2662,7 +2662,7 @@ case $target_os in · 2661 unmodified lines
26622662 SHFLAGS='-shared -Wl,-h,$$(@F)'
26632663 enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
26642664 network_extralibs="-lsocket -lnsl"
2665− add_cppflags -D__EXTENSIONS__
2665+ add_cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
26662666 # When using suncc to build, the Solaris linker will mark
26672667 # an executable with each instruction set encountered by
26682668 # the Solaris assembler. As our libraries contain their own
libavcodec/apedec.c+2−2
@@ -393,7 +393,7 @@ static inline int range_get_symbol(APEContext *ctx, · 392 unmodified lines
393393 }
394394 /** @} */ // group rangecoder
395395
396−static inline void update_rice(APERice *rice, int x)
396+static inline void update_rice(APERice *rice, unsigned int x)
397397 {
398398 int lim = rice->k ? (1 << (rice->k + 4)) : 0;
399399 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
406406
407407 static inline int ape_decode_value(APEContext *ctx, APERice *rice)
408408 {
409− int x, overflow;
409+ unsigned int x, overflow;
410410
411411 if (ctx->fileversion < 3990) {
412412 int tmpk;
libavcodec/arm/dsputil_neon.S+92−0
@@ -95,6 +95,7 @@ endfunc · 94 unmodified lines
9595 .endm
9696
9797 .macro pixels16_y2 rnd=1, avg=0
98+ sub r3, r3, #2
9899 vld1.64 {q0}, [r1], r2
99100 vld1.64 {q1}, [r1], r2
100101 1: subs r3, r3, #2
@@ -114,10 +115,25 @@ endfunc · 13 unmodified lines
114115 vst1.64 {q2}, [r0,:128], r2
115116 vst1.64 {q3}, [r0,:128], r2
116117 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+
117132 bx lr
118133 .endm
119134
120135 .macro pixels16_xy2 rnd=1, avg=0
136+ sub r3, r3, #2
121137 vld1.64 {d0-d2}, [r1], r2
122138 vld1.64 {d4-d6}, [r1], r2
123139 .ifeq \rnd
@@ -173,6 +189,42 @@ endfunc · 49 unmodified lines
173189 vaddl.u8 q11, d3, d5
174190 vst1.64 {q15}, [r0,:128], r2
175191 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+
176228 bx lr
177229 .endm
178230
@@ -228,6 +280,7 @@ endfunc · 49 unmodified lines
228280 .endm
229281
230282 .macro pixels8_y2 rnd=1, avg=0
283+ sub r3, r3, #2
231284 vld1.64 {d0}, [r1], r2
232285 vld1.64 {d1}, [r1], r2
233286 1: subs r3, r3, #2
@@ -246,10 +299,24 @@ endfunc · 12 unmodified lines
246299 vst1.64 {d4}, [r0,:64], r2
247300 vst1.64 {d5}, [r0,:64], r2
248301 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+
249315 bx lr
250316 .endm
251317
252318 .macro pixels8_xy2 rnd=1, avg=0
319+ sub r3, r3, #2
253320 vld1.64 {q0}, [r1], r2
254321 vld1.64 {q1}, [r1], r2
255322 .ifeq \rnd
@@ -291,6 +358,31 @@ endfunc · 35 unmodified lines
291358 vaddl.u8 q9, d2, d6
292359 vst1.64 {d7}, [r0,:64], r2
293360 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+
294386 bx lr
295387 .endm
296388
libavcodec/h264.h+260−236
@@ -37,14 +37,14 @@ · 36 unmodified lines
3737 #include "rectangle.h"
3838
3939 #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
4141
42−#define MAX_SPS_COUNT 32
43−#define MAX_PPS_COUNT 256
42+#define MAX_SPS_COUNT 32
43+#define MAX_PPS_COUNT 256
4444
45−#define MAX_MMCO_COUNT 66
45+#define MAX_MMCO_COUNT 66
4646
47−#define MAX_DELAYED_PIC_COUNT 16
47+#define MAX_DELAYED_PIC_COUNT 16
4848
4949 #define MAX_MBPAIR_SIZE (256*1024) // a tighter bound could be calculated if someone cares about a few bytes
5050
@@ -61,25 +61,25 @@ · 10 unmodified lines
6161 #define MAX_SLICES 16
6262
6363 #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
6666 #define FRAME_MBAFF h->mb_aff_frame
6767 #define FIELD_PICTURE (s->picture_structure != PICT_FRAME)
6868 #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)
7272 #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
7676 #define FIELD_PICTURE 0
7777 #undef IS_INTERLACED
7878 #define IS_INTERLACED(mb_type) 0
7979 #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
8383 #endif
8484 #define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF || FIELD_PICTURE)
8585
@@ -91,9 +91,9 @@ · 5 unmodified lines
9191 #define CHROMA422 (h->sps.chroma_format_idc == 2)
9292 #define CHROMA444 (h->sps.chroma_format_idc == 3)
9393
94−#define EXTENDED_SAR 255
94+#define EXTENDED_SAR 255
9595
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
9797 #define MB_TYPE_8x8DCT 0x01000000
9898 #define IS_REF0(a) ((a) & MB_TYPE_REF0)
9999 #define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT)
@@ -108,7 +108,7 @@ · 8 unmodified lines
108108
109109 /* NAL unit types */
110110 enum {
111− NAL_SLICE=1,
111+ NAL_SLICE = 1,
112112 NAL_DPA,
113113 NAL_DPB,
114114 NAL_DPC,
@@ -121,17 +121,17 @@ enum { · 6 unmodified lines
121121 NAL_END_STREAM,
122122 NAL_FILLER_DATA,
123123 NAL_SPS_EXT,
124− NAL_AUXILIARY_SLICE=19
124+ NAL_AUXILIARY_SLICE = 19
125125 };
126126
127127 /**
128128 * SEI message types
129129 */
130130 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)
135135 } SEI_Type;
136136
137137 /**
@@ -152,8 +152,7 @@ typedef enum { · 14 unmodified lines
152152 /**
153153 * Sequence parameter set
154154 */
155−typedef struct SPS{
156−
155+typedef struct SPS {
157156 int profile_idc;
158157 int level_idc;
159158 int chroma_format_idc;
@@ -170,9 +169,9 @@ typedef struct SPS{ · 10 unmodified lines
170169 int mb_width; ///< pic_width_in_mbs_minus1 + 1
171170 int mb_height; ///< pic_height_in_map_units_minus1 + 1
172171 int frame_mbs_only_flag;
173− int mb_aff; ///<mb_adaptive_frame_field_flag
172+ int mb_aff; ///< mb_adaptive_frame_field_flag
174173 int direct_8x8_inference_flag;
175− int crop; ///< frame_cropping_flag
174+ int crop; ///< frame_cropping_flag
176175 unsigned int crop_left; ///< frame_cropping_rect_left_offset
177176 unsigned int crop_right; ///< frame_cropping_rect_right_offset
178177 unsigned int crop_top; ///< frame_cropping_rect_top_offset
@@ -189,7 +188,7 @@ typedef struct SPS{ · 10 unmodified lines
189188 uint32_t num_units_in_tick;
190189 uint32_t time_scale;
191190 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?
193192 int bitstream_restriction_flag;
194193 int num_reorder_frames;
195194 int scaling_matrix_present;
@@ -199,20 +198,20 @@ typedef struct SPS{ · 3 unmodified lines
199198 int vcl_hrd_parameters_present_flag;
200199 int pic_struct_present_flag;
201200 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;
211210
212211 /**
213212 * Picture parameter set
214213 */
215−typedef struct PPS{
214+typedef struct PPS {
216215 unsigned int sps_id;
217216 int cabac; ///< entropy_coding_mode_flag
218217 int pic_order_present; ///< pic_order_present_flag
@@ -225,20 +224,20 @@ typedef struct PPS{ · 6 unmodified lines
225224 int init_qs; ///< pic_init_qs_minus26 + 26
226225 int chroma_qp_index_offset[2];
227226 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
231230 uint8_t scaling_matrix4[6][16];
232231 uint8_t scaling_matrix8[6][64];
233232 uint8_t chroma_qp_table[2][QP_MAX_NUM+1]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table
234233 int chroma_qp_diff;
235−}PPS;
234+} PPS;
236235
237236 /**
238237 * Memory management control operation opcode.
239238 */
240−typedef enum MMCOOpcode{
241− MMCO_END=0,
239+typedef enum MMCOOpcode {
240+ MMCO_END = 0,
242241 MMCO_SHORT2UNUSED,
243242 MMCO_LONG2UNUSED,
244243 MMCO_SHORT2LONG,
@@ -250,7 +249,7 @@ typedef enum MMCOOpcode{ · 5 unmodified lines
250249 /**
251250 * Memory management control operation.
252251 */
253−typedef struct MMCO{
252+typedef struct MMCO {
254253 MMCOOpcode opcode;
255254 int short_pic_num; ///< pic_num without wrapping (pic_num & max_pic_num)
256255 int long_arg; ///< index, pic_num, or num long refs depending on opcode
@@ -259,18 +258,18 @@ typedef struct MMCO{ · 2 unmodified lines
259258 /**
260259 * H264Context
261260 */
262−typedef struct H264Context{
261+typedef struct H264Context {
263262 MpegEncContext s;
264263 H264DSPContext h264dsp;
265264 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
267266
268267 int qp_thresh; ///< QP threshold to skip loopfilter
269268
270269 int prev_mb_skipped;
271270 int next_mb_skipped;
272271
273− //prediction stuff
272+ // prediction stuff
274273 int chroma_pred_mode;
275274 int intra16x16_pred_mode;
276275
@@ -284,32 +283,32 @@ typedef struct H264Context{ · 7 unmodified lines
284283 int topright_type;
285284 int left_type[LEFT_MBS];
286285
287− const uint8_t * left_block;
286+ const uint8_t *left_block;
288287 int topleft_partition;
289288
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);
292291 H264PredContext hpc;
293292 unsigned int topleft_samples_available;
294293 unsigned int top_samples_available;
295294 unsigned int topright_samples_available;
296295 unsigned int left_samples_available;
297− uint8_t (*top_borders[2])[(16*3)*2];
296+ uint8_t (*top_borders[2])[(16 * 3) * 2];
298297
299298 /**
300299 * non zero coeff count cache.
301300 * is 64 if not available.
302301 */
303− DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15*8];
302+ DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15 * 8];
304303
305304 uint8_t (*non_zero_count)[48];
306305
307306 /**
308307 * Motion vector cache.
309308 */
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?
313312 #define PART_NOT_AVAILABLE -2
314313
315314 /**
@@ -321,13 +320,13 @@ typedef struct H264Context{ · 5 unmodified lines
321320 * block_offset[ 0..23] for frame macroblocks
322321 * block_offset[24..47] for field macroblocks
323322 */
324− int block_offset[2*(16*3)];
323+ int block_offset[2 * (16 * 3)];
325324
326− uint32_t *mb2b_xy; //FIXME are these 4 a good idea?
325+ uint32_t *mb2b_xy; // FIXME are these 4 a good idea?
327326 uint32_t *mb2br_xy;
328− int b_stride; //FIXME use s->b4_stride
327+ int b_stride; // FIXME use s->b4_stride
329328
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
331330 int mb_uvlinesize;
332331
333332 int emu_edge_width;
@@ -338,32 +337,32 @@ typedef struct H264Context{ · 4 unmodified lines
338337 /**
339338 * current pps
340339 */
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?
342341
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];
347346
348347 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
350349 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)
352351 int slice_type_fixed;
353352
354− //interlacing specific flags
353+ // interlacing specific flags
355354 int mb_aff_frame;
356355 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
358357
359358 DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4];
360359
361− //Weighted pred stuff
360+ // Weighted pred stuff
362361 int use_weight;
363362 int use_weight_chroma;
364363 int luma_log2_weight_denom;
365364 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
367366 int luma_weight[48][2][2];
368367 int chroma_weight[48][2][2][2];
369368 int implicit_weight[48][48][2];
@@ -373,48 +372,48 @@ typedef struct H264Context{ · 3 unmodified lines
373372 int col_fieldoff;
374373 int dist_scale_factor[16];
375374 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];
378377
379378 /**
380379 * num_ref_idx_l0/1_active_minus1 + 1
381380 */
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
384382 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
389388
390− //data partitioning
389+ // data partitioning
391390 GetBitContext intra_gb;
392391 GetBitContext inter_gb;
393392 GetBitContext *intra_gb_ptr;
394393 GetBitContext *inter_gb_ptr;
395394
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
399398
400399 /**
401400 * Cabac
402401 */
403402 CABACContext cabac;
404− uint8_t cabac_state[1024];
403+ uint8_t cabac_state[1024];
405404
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;
408407 int cbp;
409408 int top_cbp;
410409 int left_cbp;
411410 /* 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];
418417
419418 uint8_t zigzag_scan[16];
420419 uint8_t zigzag_scan8x8[64];
@@ -435,13 +434,13 @@ typedef struct H264Context{ · 14 unmodified lines
435434
436435 int is_complex;
437436
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
440439 int slice_alpha_c0_offset;
441440 int slice_beta_offset;
442441
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
445444
446445 int nal_ref_idc;
447446 int nal_unit_type;
@@ -451,37 +450,36 @@ typedef struct H264Context{ · 3 unmodified lines
451450 /**
452451 * Used to parse AVC variant of h264
453452 */
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
457456
458457 SPS *sps_buffers[MAX_SPS_COUNT];
459458 PPS *pps_buffers[MAX_PPS_COUNT];
460459
461− int dequant_coeff_pps; ///< reinit tables when pps changes
460+ int dequant_coeff_pps; ///< reinit tables when pps changes
462461
463462 uint16_t *slice_table_base;
464463
465−
466− //POC stuff
464+ // POC stuff
467465 int poc_lsb;
468466 int poc_msb;
469467 int delta_poc_bottom;
470468 int delta_poc[2];
471469 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
477475
478476 /**
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.
480478 */
481479 int curr_pic_num;
482480
483481 /**
484− * max_frame_num or 2*max_frame_num for field pics.
482+ * max_frame_num or 2 * max_frame_num for field pics.
485483 */
486484 int max_pic_num;
487485
@@ -490,7 +488,7 @@ typedef struct H264Context{ · 2 unmodified lines
490488 Picture *short_ref[32];
491489 Picture *long_ref[32];
492490 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?
494492 int last_pocs[MAX_DELAYED_PIC_COUNT];
495493 Picture *next_output_pic;
496494 int outputed_poc;
@@ -503,10 +501,10 @@ typedef struct H264Context{ · 6 unmodified lines
503501 int mmco_index;
504502 int mmco_reset;
505503
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
508506
509− int cabac_init_idc;
507+ int cabac_init_idc;
510508
511509 /**
512510 * @name Members for slice based multithreading
@@ -582,12 +580,12 @@ typedef struct H264Context{ · 69 unmodified lines
582580 */
583581 int recovery_frame;
584582
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
587585
588586 // 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
591589
592590 int cur_chroma_format_idc;
593591
@@ -598,10 +596,9 @@ typedef struct H264Context{ · 4 unmodified lines
598596 uint8_t parse_history[4];
599597 int parse_history_count;
600598 int parse_last_mb;
601−}H264Context;
602−
599+} H264Context;
603600
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).
605602 extern const uint16_t ff_h264_mb_sizes[4];
606603
607604 /**
@@ -628,13 +625,16 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length); · 20 unmodified lines
628625 * Decode a network abstraction layer unit.
629626 * @param consumed is the number of bytes used as input
630627 * @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?
632630 * @return decoded bytes, might be src+1 if no escapes
633631 */
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);
635634
636635 /**
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.
638638 */
639639 av_cold void ff_h264_free_context(H264Context *h);
640640
@@ -667,12 +667,16 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb); · 26 unmodified lines
667667
668668 void ff_generate_sliding_window_mmcos(H264Context *h);
669669
670−
671670 /**
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.
673673 */
674674 int ff_h264_check_intra4x4_pred_mode(H264Context *h);
675675
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+ */
676680 int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma);
677681
678682 void ff_h264_hl_decode_mb(H264Context *h);
@@ -683,24 +687,28 @@ av_cold void ff_h264_decode_init_vlc(void); · 4 unmodified lines
683687
684688 /**
685689 * 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
687691 */
688692 int ff_h264_decode_mb_cavlc(H264Context *h);
689693
690694 /**
691695 * 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
693697 */
694698 int ff_h264_decode_mb_cabac(H264Context *h);
695699
696700 void ff_h264_init_cabac_states(H264Context *h);
697701
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);
701705
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);
704712
705713 /**
706714 * 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
709717 */
710718 void ff_h264_reset_sei(H264Context *h);
711719
712−
713720 /*
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+ */
722729
723730 /* Scan8 organization:
724731 * 0 1 2 3 4 5 6 7
@@ -743,156 +750,173 @@ o-o o-o · 18 unmodified lines
743750 #define LUMA_DC_BLOCK_INDEX 48
744751 #define CHROMA_DC_BLOCK_INDEX 49
745752
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
761768 };
762769
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+{
764772 #if HAVE_BIGENDIAN
765− return (b&0xFFFF) + (a<<16);
773+ return (b & 0xFFFF) + (a << 16);
766774 #else
767− return (a&0xFFFF) + (b<<16);
775+ return (a & 0xFFFF) + (b << 16);
768776 #endif
769777 }
770778
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+{
772781 #if HAVE_BIGENDIAN
773− return (b&0xFF) + (a<<8);
782+ return (b & 0xFF) + (a << 8);
774783 #else
775− return (a&0xFF) + (b<<8);
784+ return (a & 0xFF) + (b << 8);
776785 #endif
777786 }
778787
779788 /**
780789 * Get the chroma qp.
781790 */
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+{
783793 return h->pps.chroma_qp_table[t][qscale];
784794 }
785795
786796 /**
787797 * Get the predicted intra4x4 prediction mode.
788798 */
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);
794805
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);
796807
797− if(min<0) return DC_PRED;
798− else return min;
808+ if (min < 0)
809+ return DC_PRED;
810+ else
811+ return min;
799812 }
800813
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;
804818
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];
809823 }
810824
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];
814829 uint8_t *nnz_cache = h->non_zero_count_cache;
815830
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]);
830845 }
831846 }
832847
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)
835853 {
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)) {
846865 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);
852871 }
853872 }
854873
855874 {
856875 int8_t *ref_index = &s->current_picture.f.ref_index[list][b8_xy];
857876 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]];
862881 }
863882 }
864883
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;
870890
871− if(USES_LIST(mb_type, 0)){
891+ if (USES_LIST(mb_type, 0)) {
872892 write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0);
873− }else{
893+ } else {
874894 fill_rectangle(&s->current_picture.f.ref_index[0][b8_xy],
875895 2, 2, 2, (uint8_t)LIST_NOT_USED, 1);
876896 }
877− if(USES_LIST(mb_type, 1)){
897+ if (USES_LIST(mb_type, 1))
878898 write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 1);
879− }
880899
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;
887906 }
888907 }
889908 }
890909
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));
894916 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));
896920 }
897921
898922 #endif /* AVCODEC_H264_H */
libavcodec/h264_mvpred.h+524−481
@@ -35,53 +35,53 @@ · 34 unmodified lines
3535 //#undef NDEBUG
3636 #include <assert.h>
3737
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;
4143
4244 /* there is no consistent mapping of mvs to neighboring locations that will
4345 * 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) {
5960 const uint32_t *mb_types = s->current_picture_ptr->f.mb_type;
6061 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];
6364
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));
6768 }
68− if(MB_FIELD
69− && !IS_INTERLACED(h->left_type[0])){
69+ if (MB_FIELD && !IS_INTERLACED(h->left_type[0])) {
7070 // 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);
7272 }
7373 }
7474 #undef SET_DIAG_MV
7575 }
7676
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];
7979 return topright_ref;
80− }else{
80+ } else {
8181 tprintf(s->avctx, "topright MV not available\n");
8282
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];
8585 }
8686 }
8787
@@ -92,53 +92,61 @@ static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, · 4 unmodified lines
9292 * @param mx the x component of the predicted motion vector
9393 * @param my the y component of the predicted motion vector
9494 */
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;
102105 int diagonal_ref, match_count;
103106
104− assert(part_width==1 || part_width==2 || part_width==4);
107+ assert(part_width == 1 || part_width == 2 || part_width == 4);
105108
106109 /* 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);
116119 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];
130133 }
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]);
138143 }
139144 }
140145
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);
142150 }
143151
144152 /**
@@ -147,27 +155,32 @@ static av_always_inline void pred_motion(H264Context * const h, int n, int part_ · 2 unmodified lines
147155 * @param mx the x component of the predicted motion vector
148156 * @param my the y component of the predicted motion vector
149157 */
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];
160172 return;
161173 }
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];
165177
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);
167180
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];
171184 return;
172185 }
173186 }
@@ -182,29 +195,34 @@ static av_always_inline void pred_16x8_motion(H264Context * const h, int n, int · 8 unmodified lines
182195 * @param mx the x component of the predicted motion vector
183196 * @param my the y component of the predicted motion vector
184197 */
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];
195212 return;
196213 }
197− }else{
198− const int16_t * C;
214+ } else {
215+ const int16_t *C;
199216 int diagonal_ref;
200217
201− diagonal_ref= fetch_diagonal_mv(h, &C, scan8[4], list, 2);
218+ diagonal_ref = fetch_diagonal_mv(h, &C, scan8[4], list, 2);
202219
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);
204222
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];
208226 return;
209227 }
210228 }
@@ -213,168 +231,174 @@ static av_always_inline void pred_8x16_motion(H264Context * const h, int n, int · 2 unmodified lines
213231 pred_motion(h, n, 2, list, ref, mx, my);
214232 }
215233
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+ } \
233251 }
234252
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 };
237256 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];
241260 int top_ref, left_ref, diagonal_ref, match_count, mx, my;
242261 const int16_t *A, *B, *C;
243262 int b_stride = h->b_stride;
244263
245264 fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1);
246265
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?
250270 */
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]];
254274 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)))
256276 goto zeromv;
257− }
258− }else if(h->left_type[LTOP]){
277+ } else if (h->left_type[LTOP]) {
259278 left_ref = LIST_NOT_USED;
260− A = zeromv;
261− }else{
279+ A = zeromv;
280+ } else {
262281 goto zeromv;
263282 }
264283
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];
268287 FIX_MV_MBAFF(h->top_type, top_ref, B, 1);
269− if(!(top_ref | AV_RN32A(B))){
288+ if (!(top_ref | AV_RN32A(B)))
270289 goto zeromv;
271− }
272− }else if(h->top_type){
290+ } else if (h->top_type) {
273291 top_ref = LIST_NOT_USED;
274− B = zeromv;
275− }else{
292+ B = zeromv;
293+ } else {
276294 goto zeromv;
277295 }
278296
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);
280299
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];
284303 FIX_MV_MBAFF(h->topright_type, diagonal_ref, C, 2);
285− }else if(h->topright_type){
304+ } else if (h->topright_type) {
286305 diagonal_ref = LIST_NOT_USED;
287306 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)];
292313 FIX_MV_MBAFF(h->topleft_type, diagonal_ref, C, 2);
293− }else if(h->topleft_type){
314+ } else if (h->topleft_type) {
294315 diagonal_ref = LIST_NOT_USED;
295− C = zeromv;
296− }else{
316+ C = zeromv;
317+ } else {
297318 diagonal_ref = PART_NOT_AVAILABLE;
298− C = zeromv;
319+ C = zeromv;
299320 }
300321 }
301322
302− match_count= !diagonal_ref + !top_ref + !left_ref;
323+ match_count = !diagonal_ref + !top_ref + !left_ref;
303324 tprintf(h->s.avctx, "pred_pskip_motion match_count=%d\n", match_count);
304− if(match_count > 1){
325+ if (match_count > 1) {
305326 mx = mid_pred(A[0], B[0], C[0]);
306327 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) {
309330 mx = A[0];
310331 my = A[1];
311− }else if(!top_ref){
332+ } else if (!top_ref) {
312333 mx = B[0];
313334 my = B[1];
314− }else{
335+ } else {
315336 mx = C[0];
316337 my = C[1];
317338 }
318− }else{
339+ } else {
319340 mx = mid_pred(A[0], B[0], C[0]);
320341 my = mid_pred(A[1], B[1], C[1]);
321342 }
322343
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);
324345 return;
346+
325347 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);
327349 return;
328350 }
329351
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;
333356 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 }
339362 };
340363
341− h->topleft_partition= -1;
364+ h->topleft_partition = -1;
342365
343− top_xy = mb_xy - (s->mb_stride << MB_FIELD);
366+ top_xy = mb_xy - (s->mb_stride << MB_FIELD);
344367
345368 /* Wow, what a mess, why didn't they simplify the interlacing & intra
346369 * stuff, I can't imagine that these complex rules are worth it. */
347370
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;
351374 h->left_block = left_block_options[0];
352− if(FRAME_MBAFF){
375+ if (FRAME_MBAFF) {
353376 const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]);
354377 const int curr_mb_field_flag = IS_INTERLACED(mb_type);
355− if(s->mb_y&1){
378+ if (s->mb_y & 1) {
356379 if (left_mb_field_flag != curr_mb_field_flag) {
357380 left_xy[LBOT] = left_xy[LTOP] = mb_xy - s->mb_stride - 1;
358381 if (curr_mb_field_flag) {
359382 left_xy[LBOT] += s->mb_stride;
360− h->left_block = left_block_options[3];
383+ h->left_block = left_block_options[3];
361384 } else {
362385 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 */
364388 h->topleft_partition = 0;
365− h->left_block = left_block_options[1];
389+ h->left_block = left_block_options[1];
366390 }
367391 }
368− }else{
369− if(curr_mb_field_flag){
392+ } else {
393+ if (curr_mb_field_flag) {
370394 topleft_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy - 1] >> 7) & 1) - 1);
371395 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);
373397 }
374398 if (left_mb_field_flag != curr_mb_field_flag) {
375399 if (curr_mb_field_flag) {
376400 left_xy[LBOT] += s->mb_stride;
377− h->left_block = left_block_options[3];
401+ h->left_block = left_block_options[3];
378402 } else {
379403 h->left_block = left_block_options[2];
380404 }
@@ -382,9 +406,9 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){ · 1 unmodified line
382406 }
383407 }
384408
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;
388412 h->left_mb_xy[LTOP] = left_xy[LTOP];
389413 h->left_mb_xy[LBOT] = left_xy[LBOT];
390414 //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
395419 h->left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]];
396420 h->left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]];
397421
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) {
404431 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;
407436 }
408437 }
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;
410440 }
411441
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;
414445 int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS];
415446 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;
417448 int i;
418449 uint8_t *nnz;
419450 uint8_t *nnz_cache;
420451
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;
444475 }
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;
450481 }
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;
454485 }
455− }else{
486+ } else {
456487 int left_typei = s->current_picture.f.mb_type[left_xy[LTOP] + s->mb_stride];
457488
458489 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;
462493 }
463494 }
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;
468499 }
469500 }
470501
471− if(!(topleft_type & type_mask))
472− h->topleft_samples_available&= 0x7FFF;
502+ if (!(topleft_type & type_mask))
503+ h->topleft_samples_available &= 0x7FFF;
473504
474− if(!(topright_type & type_mask))
475− h->topright_samples_available&= 0xFBFF;
505+ if (!(topright_type & type_mask))
506+ h->topright_samples_available &= 0xFBFF;
476507
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);
485516 }
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);
494525 }
495526 }
496527 }
497528 }
498529
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);
519556 }
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− }
526557
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;
545584 }
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;
553585 }
554− }
555586
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+ }
570601 }
571602 }
572− }
573603
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)) {
575605 int list;
576606 int b_stride = h->b_stride;
577− for(list=0; list<h->list_count; list++){
607+ for (list = 0; list < h->list_count; list++) {
578608 int8_t *ref_cache = &h->ref_cache[list][scan8[0]];
579609 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))
583613 continue;
584− }
585614 assert(!(IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred));
586615
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);
597627 }
598628
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+ }
614648 }
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 {
623656 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;
625659 }
626660 }
627661
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;
635670 }
636671 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;
645682 }
646683 }
647684
648− if((mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2)) && !FRAME_MBAFF)
685+ if ((mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2)) && !FRAME_MBAFF)
649686 continue;
650687
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]);
665702 }
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]);
673710 }
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]);
681718 }
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) {
685722 uint8_t *direct_cache = &h->direct_cache[scan8[0]];
686723 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));
697736 }
698737
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)];
703742 else
704− direct_cache[-1 + 0*8]= MB_TYPE_16x16>>1;
743+ direct_cache[-1 + 0 * 8] = MB_TYPE_16x16 >> 1;
705744
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)];
710749 else
711− direct_cache[-1 + 2*8]= MB_TYPE_16x16>>1;
750+ direct_cache[-1 + 2 * 8] = MB_TYPE_16x16 >> 1;
712751 }
713752 }
714753 }
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+
734777 MAP_MVS
778+ } else {
779+
735780 #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+
743788 MAP_MVS
744789 #undef MAP_F2F
745790 }
@@ -747,36 +792,34 @@ static void fill_decode_caches(H264Context *h, int mb_type){ · 1 unmodified line
747792 }
748793 }
749794
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]);
751796 }
752797
753798 /**
754799 * decodes a P_SKIP or B_SKIP macroblock
755800 */
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;
760806
761807 memset(h->non_zero_count[mb_xy], 0, 48);
762808
763− if(MB_FIELD)
764− mb_type|= MB_TYPE_INTERLACED;
809+ if (MB_FIELD)
810+ mb_type |= MB_TYPE_INTERLACED;
765811
766− if( h->slice_type_nos == AV_PICTURE_TYPE_B )
767− {
812+ if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
768813 // 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) {
771816 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 ...
773818 }
774819 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;
780823
781824 fill_decode_neighbors(h, mb_type);
782825 pred_pskip_motion(h);
@@ -785,8 +828,8 @@ static void av_unused decode_mb_skip(H264Context *h){ · 2 unmodified lines
785828 write_back_motion(h, mb_type);
786829 s->current_picture.f.mb_type[mb_xy] = mb_type;
787830 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;
790833 }
791834
792835 #endif /* AVCODEC_H264_MVPRED_H */
libavcodec/h264data.h+186−183
@@ -30,240 +30,243 @@ · 29 unmodified lines
3030 #define AVCODEC_H264DATA_H
3131
3232 #include <stdint.h>
33+
3334 #include "libavutil/rational.h"
3435 #include "mpegvideo.h"
3536 #include "h264.h"
3637
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+};
3742
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
4547 };
4648
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
5153 };
5254
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,
5860 };
5961
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,
6567 };
6668
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,
7274 };
7375
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,
7981 };
8082
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,
8486 };
8587
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,
9193 };
9294
9395 // 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,
111113 };
112114
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,
130132 };
131133
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,
149151 };
150152
151−typedef struct IMbInfo{
153+typedef struct IMbInfo {
152154 uint16_t type;
153155 uint8_t pred_mode;
154156 uint8_t cbp;
155157 } IMbInfo;
156158
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 },
184186 };
185187
186−typedef struct PMbInfo{
188+typedef struct PMbInfo {
187189 uint16_t type;
188190 uint8_t partition_count;
189191 } PMbInfo;
190192
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 },
197199 };
198200
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 },
204206 };
205207
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, },
230232 };
231233
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, },
246248 };
247249
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 },
255257 };
256258
257259 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
259261 };
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 },
267270 };
268271
269272 #endif /* AVCODEC_H264DATA_H */
libavcodec/h264dsp.h+65−31
@@ -28,56 +28,90 @@ · 27 unmodified lines
2828 #define AVCODEC_H264DSP_H
2929
3030 #include <stdint.h>
31+
3132 #include "dsputil.h"
3233
3334 typedef void (*h264_weight_func)(uint8_t *block, int stride, int height,
3435 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);
3739
3840 /**
3941 * Context for storing H.264 DSP functions
4042 */
41−typedef struct H264DSPContext{
43+typedef struct H264DSPContext {
4244 /* weighted MC */
4345 h264_weight_func weight_h264_pixels_tab[4];
4446 h264_biweight_func biweight_h264_pixels_tab[4];
4547
4648 /* 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);
5055 /* 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);
6075 // 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);
6380
6481 /* 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);
6990
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);
75105 void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul);
76−}H264DSPContext;
106+} H264DSPContext;
77107
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);
82116
83117 #endif /* AVCODEC_H264DSP_H */
libavcodec/h264pred.h+45−36
@@ -35,18 +35,18 @@ · 34 unmodified lines
3535 * Prediction types
3636 */
3737 //@{
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
4747
4848 // DC edge (not for VP8)
49−#define LEFT_DC_PRED 9
49+#define LEFT_DC_PRED 9
5050 #define TOP_DC_PRED 10
5151 #define DC_128_PRED 11
5252
@@ -56,7 +56,7 @@ · 3 unmodified lines
5656 #define VERT_LEFT_PRED_RV40_NODOWN 14
5757
5858 // 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
6060 #define VERT_VP8_PRED 10 ///< for VP8, #VERT_PRED is the average of
6161 ///< (left col+cur col x2+right col) / 4;
6262 ///< this is the "unaveraged" one
@@ -65,44 +65,53 @@ · 2 unmodified lines
6565 #define DC_127_PRED 12
6666 #define DC_129_PRED 13
6767
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
7272
7373 // 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
7777
7878 // 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
8282 #define ALZHEIMER_DC_0L0_PRED8x8 10
8383
8484 // 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
8787 //@}
8888
8989 /**
9090 * Context for storing H.264 prediction functions
9191 */
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);
9797
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;
103109
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);
107116
108117 #endif /* AVCODEC_H264PRED_H */
libavcodec/vcr1.c+102−115
@@ -21,39 +21,57 @@ · 20 unmodified lines
2121
2222 /**
2323 * @file
24− * ati vcr1 codec.
24+ * ATI VCR1 codec
2525 */
2626
2727 #include "avcodec.h"
2828 #include "dsputil.h"
2929
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 {
3931 AVFrame picture;
4032 int delta[16];
4133 int offset[4];
4234 } VCR1Context;
4335
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)
4765 {
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;
5472 int i, x, y;
5573
56− if(p->data[0])
74+ if (p->data[0])
5775 avctx->release_buffer(avctx, p);
5876
5977 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
6179 return AVERROR(EINVAL);
6280 }
6381
64− p->reference= 0;
65− if(avctx->get_buffer(avctx, p) < 0){
82+ p->reference = 0;
83+ if (avctx->get_buffer(avctx, p) < 0) {
6684 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
6785 return -1;
6886 }
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;
7189
72− for(i=0; i<16; i++){
73− a->delta[i]= *(bytestream++);
90+ for (i = 0; i < 16; i++) {
91+ a->delta[i] = *bytestream++;
7492 bytestream++;
7593 }
7694
77− for(y=0; y<avctx->height; y++){
95+ for (y = 0; y < avctx->height; y++) {
7896 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]];
8098
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]];
84102
85− for(i=0; i<4; i++)
86− a->offset[i]= *(bytestream++);
103+ for (i = 0; i < 4; i++)
104+ a->offset[i] = *bytestream++;
87105
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;
95113
96− *(cb++) = bytestream[3];
97− *(cr++) = bytestream[1];
114+ *cb++ = bytestream[3];
115+ *cr++ = bytestream[1];
98116
99− bytestream+= 4;
117+ bytestream += 4;
100118 }
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;
115133 }
116134 }
117135 }
@@ -122,62 +140,6 @@ static int decode_frame(AVCodecContext *avctx, · 4 unmodified lines
122140 return buf_size;
123141 }
124142
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−
181143 AVCodec ff_vcr1_decoder = {
182144 .name = "vcr1",
183145 .type = AVMEDIA_TYPE_VIDEO,
@@ -190,14 +152,39 @@ AVCodec ff_vcr1_decoder = { · 6 unmodified lines
190152 .long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"),
191153 };
192154
155+/* Disable the encoder. */
156+#undef CONFIG_VCR1_ENCODER
157+#define CONFIG_VCR1_ENCODER 0
158+
193159 #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+
194181 AVCodec ff_vcr1_encoder = {
195182 .name = "vcr1",
196183 .type = AVMEDIA_TYPE_VIDEO,
197184 .id = CODEC_ID_VCR1,
198185 .priv_data_size = sizeof(VCR1Context),
199− .init = encode_init,
186+ .init = common_init,
200187 .encode = encode_frame,
201188 .long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"),
202189 };
203−#endif
190+#endif /* CONFIG_VCR1_ENCODER */
libavcodec/x86/dsputil_mmx.c+16−0
@@ -1792,6 +1792,22 @@ QPEL_2TAP(avg_, 16, 3dnow) · 1791 unmodified lines
17921792 QPEL_2TAP(put_, 8, 3dnow)
17931793 QPEL_2TAP(avg_, 8, 3dnow)
17941794
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+}
17951811
17961812 #if HAVE_YASM
17971813 typedef void emu_edge_core_func(uint8_t *buf, const uint8_t *src,
libavcodec/x86/dsputil_mmx.h+5−0
@@ -199,6 +199,11 @@ void ff_avg_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); · 198 unmodified lines
199199 void ff_put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd);
200200 void ff_avg_vc1_mspel_mc00_mmx2(uint8_t *dst, const uint8_t *src, int stride, int rnd);
201201
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+
202207 void ff_mmx_idct(DCTELEM *block);
203208 void ff_mmxext_idct(DCTELEM *block);
204209
libavcodec/x86/rv40dsp.asm+313−3
@@ -1,5 +1,7 @@
11 ;******************************************************************************
22 ;* 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>
35 ;* Copyright (C) 2012 Christophe Gisquet <christophe.gisquet@gmail.com>
46 ;*
57 ;* This file is part of Libav.
@@ -25,11 +27,319 @@ · 19 unmodified lines
2527 SECTION_RODATA
2628
2729 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
3075
3176 SECTION .text
3277
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+
33343 ; %1=5bits weights?, %2=dst %3=src1 %4=src3 %5=stride if sse2
34344 %macro RV40_WCORE 4-5
35345 movh m4, [%3 + r6 + 0]
@@ -143,7 +453,7 @@ SECTION .text · 107 unmodified lines
143453 %macro RV40_WEIGHT 3
144454 cglobal rv40_weight_func_%1_%2, 6, 7, 8
145455 %if cpuflag(ssse3)
146− mova m1, [shift_round]
456+ mova m1, [pw_1024]
147457 %else
148458 mova m1, [pw_16]
149459 %endif
libavcodec/x86/rv40dsp_init.c+146−0
@@ -22,8 +22,11 @@ · 21 unmodified lines
2222 /**
2323 * @file
2424 * 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
2527 */
2628
29+#include "libavcodec/x86/dsputil_mmx.h"
2730 #include "libavcodec/rv34dsp.h"
2831
2932 void ff_put_rv40_chroma_mc8_mmx (uint8_t *dst, uint8_t *src,
@@ -53,6 +56,132 @@ DECLARE_WEIGHT(mmx) · 23 unmodified lines
5356 DECLARE_WEIGHT(sse2)
5457 DECLARE_WEIGHT(ssse3)
5558
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+
56185 void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp)
57186 {
58187 #if HAVE_YASM
@@ -65,25 +194,42 @@ void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp) · 6 unmodified lines
65194 c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_mmx;
66195 c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_mmx;
67196 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
68204 }
69205 if (mm_flags & AV_CPU_FLAG_MMX2) {
70206 c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_mmx2;
71207 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
72211 } else if (mm_flags & AV_CPU_FLAG_3DNOW) {
73212 c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_3dnow;
74213 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
75217 }
76218 if (mm_flags & AV_CPU_FLAG_SSE2) {
77219 c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_sse2;
78220 c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_sse2;
79221 c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_sse2;
80222 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)
81225 }
82226 if (mm_flags & AV_CPU_FLAG_SSSE3) {
83227 c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_ssse3;
84228 c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_ssse3;
85229 c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_ssse3;
86230 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)
87233 }
88234 #endif
89235 }
libavfilter/Makefile+1−0
@@ -21,6 +21,7 @@ HEADERS = asrc_abuffer.h \ · 20 unmodified lines
2121 vsrc_buffer.h \
2222
2323 OBJS = allfilters.o \
24+ audio.o \
2425 avfilter.o \
2526 avfiltergraph.o \
2627 buffersink.o \
libavfilter/af_aconvert.c+2−2
@@ -144,7 +144,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 143 unmodified lines
144144 AConvertContext *aconvert = inlink->dst->priv;
145145 const int n = insamplesref->audio->nb_samples;
146146 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);
148148
149149 swr_convert(aconvert->swr, outsamplesref->data, n,
150150 (void *)insamplesref->data, n);
@@ -153,7 +153,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 2 unmodified lines
153153 outsamplesref->audio->channel_layout = outlink->channel_layout;
154154 outsamplesref->audio->planar = outlink->planar;
155155
156− avfilter_filter_samples(outlink, outsamplesref);
156+ ff_filter_samples(outlink, outsamplesref);
157157 avfilter_unref_buffer(insamplesref);
158158 }
159159
libavfilter/af_aformat.c+1−1
@@ -89,7 +89,7 @@ static int query_formats(AVFilterContext *ctx) · 88 unmodified lines
8989
9090 static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref)
9191 {
92− avfilter_filter_samples(inlink->dst->outputs[0], insamplesref);
92+ ff_filter_samples(inlink->dst->outputs[0], insamplesref);
9393 }
9494
9595 AVFilter avfilter_af_aformat = {
libavfilter/af_amerge.c+2−2
@@ -208,7 +208,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 207 unmodified lines
208208
209209 nb_samples = FFMIN(am->queue[0].nb_samples,
210210 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,
212212 nb_samples);
213213 outs = outbuf->data[0];
214214 for (i = 0; i < 2; i++) {
@@ -264,7 +264,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 49 unmodified lines
264264 am->queue[i].nb_buf * sizeof(**inbuf));
265265 }
266266 }
267− avfilter_filter_samples(ctx->outputs[0], outbuf);
267+ ff_filter_samples(ctx->outputs[0], outbuf);
268268 }
269269
270270 AVFilter avfilter_af_amerge = {
libavfilter/af_anull.c+3−2
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 * null audio filter
2222 */
2323
24+#include "audio.h"
2425 #include "avfilter.h"
2526
2627 AVFilter avfilter_af_anull = {
@@ -31,8 +32,8 @@ AVFilter avfilter_af_anull = { · 4 unmodified lines
3132
3233 .inputs = (const AVFilterPad[]) {{ .name = "default",
3334 .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 },
3637 { .name = NULL}},
3738
3839 .outputs = (const AVFilterPad[]) {{ .name = "default",
libavfilter/af_aresample.c+2−2
@@ -92,7 +92,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 91 unmodified lines
9292 const int n_in = insamplesref->audio->nb_samples;
9393 int n_out = n_in * aresample->ratio;
9494 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);
9696
9797 n_out = swr_convert(aresample->swr, outsamplesref->data, n_out,
9898 (void *)insamplesref->data, n_in);
@@ -103,7 +103,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 4 unmodified lines
103103 outsamplesref->pts = insamplesref->pts == AV_NOPTS_VALUE ? AV_NOPTS_VALUE :
104104 av_rescale(outlink->sample_rate, insamplesref->pts, inlink ->sample_rate);
105105
106− avfilter_filter_samples(outlink, outsamplesref);
106+ ff_filter_samples(outlink, outsamplesref);
107107 avfilter_unref_buffer(insamplesref);
108108 }
109109
libavfilter/af_ashowinfo.c+2−2
@@ -83,7 +83,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) · 82 unmodified lines
8383 av_log(ctx, AV_LOG_INFO, "]\n");
8484
8585 showinfo->frame++;
86− avfilter_filter_samples(inlink->dst->outputs[0], samplesref);
86+ ff_filter_samples(inlink->dst->outputs[0], samplesref);
8787 }
8888
8989 AVFilter avfilter_af_ashowinfo = {
@@ -95,7 +95,7 @@ AVFilter avfilter_af_ashowinfo = { · 5 unmodified lines
9595
9696 .inputs = (const AVFilterPad[]) {{ .name = "default",
9797 .type = AVMEDIA_TYPE_AUDIO,
98− .get_audio_buffer = avfilter_null_get_audio_buffer,
98+ .get_audio_buffer = ff_null_get_audio_buffer,
9999 .filter_samples = filter_samples,
100100 .min_perms = AV_PERM_READ, },
101101 { .name = NULL}},
libavfilter/af_asplit.c+3−3
@@ -27,9 +27,9 @@ · 26 unmodified lines
2727
2828 static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
2929 {
30− avfilter_filter_samples(inlink->dst->outputs[0],
30+ ff_filter_samples(inlink->dst->outputs[0],
3131 avfilter_ref_buffer(insamples, ~AV_PERM_WRITE));
32− avfilter_filter_samples(inlink->dst->outputs[1],
32+ ff_filter_samples(inlink->dst->outputs[1],
3333 avfilter_ref_buffer(insamples, ~AV_PERM_WRITE));
3434 avfilter_unref_buffer(insamples);
3535 }
@@ -41,7 +41,7 @@ AVFilter avfilter_af_asplit = { · 5 unmodified lines
4141 .inputs = (const AVFilterPad[]) {
4242 { .name = "default",
4343 .type = AVMEDIA_TYPE_AUDIO,
44− .get_audio_buffer = avfilter_null_get_audio_buffer,
44+ .get_audio_buffer = ff_null_get_audio_buffer,
4545 .filter_samples = filter_samples, },
4646 { .name = NULL}
4747 },
libavfilter/af_astreamsync.c+1−1
@@ -119,7 +119,7 @@ static void send_out(AVFilterContext *ctx, int out_id) · 118 unmodified lines
119119 av_q2d(ctx->outputs[out_id]->time_base) * buf->pts;
120120 as->var_values[VAR_T1 + out_id] += buf->audio->nb_samples /
121121 (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);
123123 queue->nb--;
124124 queue->tail = (queue->tail + 1) % QUEUE_SIZE;
125125 if (as->req[out_id])
libavfilter/af_earwax.c+2−2
@@ -122,7 +122,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 121 unmodified lines
122122 AVFilterLink *outlink = inlink->dst->outputs[0];
123123 int16_t *taps, *endin, *in, *out;
124124 AVFilterBufferRef *outsamples =
125− avfilter_get_audio_buffer(inlink, AV_PERM_WRITE,
125+ ff_get_audio_buffer(inlink, AV_PERM_WRITE,
126126 insamples->audio->nb_samples);
127127 avfilter_copy_buffer_ref_props(outsamples, insamples);
128128
@@ -141,7 +141,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 12 unmodified lines
141141 // save part of input for next round
142142 memcpy(taps, endin, NUMTAPS * sizeof(*taps));
143143
144− avfilter_filter_samples(outlink, outsamples);
144+ ff_filter_samples(outlink, outsamples);
145145 avfilter_unref_buffer(insamples);
146146 }
147147
libavfilter/af_pan.c+2−2
@@ -340,7 +340,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 339 unmodified lines
340340 {
341341 int n = insamples->audio->nb_samples;
342342 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);
344344 PanContext *pan = inlink->dst->priv;
345345
346346 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
348348 outsamples->audio->channel_layout = outlink->channel_layout;
349349 outsamples->audio->planar = outlink->planar;
350350
351− avfilter_filter_samples(outlink, outsamples);
351+ ff_filter_samples(outlink, outsamples);
352352 avfilter_unref_buffer(insamples);
353353 }
354354
libavfilter/af_silencedetect.c+2−2
@@ -123,7 +123,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 122 unmodified lines
123123 }
124124 }
125125
126− avfilter_filter_samples(inlink->dst->outputs[0], insamples);
126+ ff_filter_samples(inlink->dst->outputs[0], insamples);
127127 }
128128
129129 static int query_formats(AVFilterContext *ctx)
@@ -163,7 +163,7 @@ AVFilter avfilter_af_silencedetect = { · 33 unmodified lines
163163 .inputs = (const AVFilterPad[]) {
164164 { .name = "default",
165165 .type = AVMEDIA_TYPE_AUDIO,
166− .get_audio_buffer = avfilter_null_get_audio_buffer,
166+ .get_audio_buffer = ff_null_get_audio_buffer,
167167 .filter_samples = filter_samples, },
168168 { .name = NULL }
169169 },
libavfilter/af_volume.c+1−1
@@ -167,7 +167,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 166 unmodified lines
167167 }
168168 }
169169 }
170− avfilter_filter_samples(outlink, insamples);
170+ ff_filter_samples(outlink, insamples);
171171 }
172172
173173 AVFilter avfilter_af_volume = {
libavfilter/asrc_aevalsrc.c+2−2
@@ -205,7 +205,7 @@ static int request_frame(AVFilterLink *outlink) · 204 unmodified lines
205205 if (eval->duration >= 0 && t > eval->duration)
206206 return AVERROR_EOF;
207207
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);
209209
210210 /* evaluate expression for each single sample and for each channel */
211211 for (i = 0; i < eval->nb_samples; i++, eval->n++) {
@@ -223,7 +223,7 @@ static int request_frame(AVFilterLink *outlink) · 11 unmodified lines
223223 samplesref->audio->sample_rate = eval->sample_rate;
224224 eval->pts += eval->nb_samples;
225225
226− avfilter_filter_samples(outlink, samplesref);
226+ ff_filter_samples(outlink, samplesref);
227227
228228 return 0;
229229 }
libavfilter/asrc_anullsrc.c+2−2
@@ -108,13 +108,13 @@ static int request_frame(AVFilterLink *outlink) · 107 unmodified lines
108108 AVFilterBufferRef *samplesref;
109109
110110 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);
112112 samplesref->pts = null->pts;
113113 samplesref->pos = -1;
114114 samplesref->audio->channel_layout = null->channel_layout;
115115 samplesref->audio->sample_rate = outlink->sample_rate;
116116
117− avfilter_filter_samples(outlink, avfilter_ref_buffer(samplesref, ~0));
117+ ff_filter_samples(outlink, avfilter_ref_buffer(samplesref, ~0));
118118 avfilter_unref_buffer(samplesref);
119119
120120 null->pts += null->nb_samples;
libavfilter/audio.c+291−0
@@ -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+}
libavfilter/audio.h+65−0
@@ -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 */
libavfilter/avfilter.c+4−170
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "libavutil/imgutils.h"
2828 #include "libavutil/avassert.h"
2929 #include "libavutil/avstring.h"
30+
3031 #include "avfilter.h"
3132 #include "internal.h"
3233
@@ -410,7 +411,7 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end) · 377 unmodified lines
410411 av_dlog(ctx, "]%s", end ? "\n" : "");
411412 }
412413
413−static void ff_dlog_link(void *ctx, AVFilterLink *link, int end)
414+void ff_dlog_link(void *ctx, AVFilterLink *link, int end)
414415 {
415416 if (link->type == AVMEDIA_TYPE_VIDEO) {
416417 av_dlog(ctx,
@@ -434,8 +435,6 @@ static void ff_dlog_link(void *ctx, AVFilterLink *link, int end) · 17 unmodified lines
434435 }
435436 }
436437
437−#define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func)
438−
439438 AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
440439 {
441440 AVFilterBufferRef *ret = NULL;
@@ -501,133 +500,6 @@ fail: · 59 unmodified lines
501500 return NULL;
502501 }
503502
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−
631503 int avfilter_request_frame(AVFilterLink *link)
632504 {
633505 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
657529 return min;
658530 }
659531
660−static void update_link_current_pts(AVFilterLink *link, int64_t pts)
532+void ff_update_link_current_pts(AVFilterLink *link, int64_t pts)
661533 {
662534 if (pts == AV_NOPTS_VALUE)
663535 return;
@@ -706,7 +578,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 42 unmodified lines
706578 }
707579
708580 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);
710582 }
711583
712584 void avfilter_end_frame(AVFilterLink *link)
@@ -778,44 +650,6 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha · 65 unmodified lines
778650 return AVERROR(ENOSYS);
779651 }
780652
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−
819653 #define MAX_REGISTERED_AVFILTERS_NB 128
820654
821655 static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1];
libavfilter/avfilter.h+6−39
@@ -430,7 +430,8 @@ struct AVFilterPad { · 429 unmodified lines
430430 *
431431 * Input audio pads only.
432432 */
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);
434435
435436 /**
436437 * 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
508509 /** default handler for end_frame() for video inputs */
509510 void avfilter_default_end_frame(AVFilterLink *link);
510511
511−/** default handler for filter_samples() for audio inputs */
512−void avfilter_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
513−
514512 /** default handler for get_video_buffer() for video inputs */
515513 AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
516514 int perms, int w, int h);
517515
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);
521516
522517 /**
523518 * 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
541536 /** end_frame() handler for filters which simply pass video along */
542537 void avfilter_null_end_frame(AVFilterLink *link);
543538
544−/** filter_samples() handler for filters which simply pass audio along */
545−void avfilter_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
546−
547539 /** get_video_buffer() handler for filters which simply pass video along */
548540 AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
549541 int perms, int w, int h);
550542
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−
555543 /**
556544 * Filter definition. This defines the pads a filter contains, and all the
557545 * callback functions used to interact with the filter.
@@ -665,7 +653,7 @@ struct AVFilterLink { · 107 unmodified lines
665653 AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
666654 /* These parameters apply only to audio */
667655 uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/audioconvert.h)
668−#if LIBAVFILTER_VERSION_MAJOR < 3
656+#if FF_API_SAMPLERATE64
669657 int64_t sample_rate; ///< samples per second
670658 #else
671659 int sample_rate; ///< samples per second
@@ -790,19 +778,6 @@ AVFilterBufferRef * · 118 unmodified lines
790778 avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
791779 int w, int h, enum PixelFormat format);
792780
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−
806781 /**
807782 * Create an audio buffer reference wrapped around an already
808783 * allocated samples buffer.
@@ -904,17 +879,7 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); · 95 unmodified lines
904879 */
905880 int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags);
906881
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. */
918883 void avfilter_register_all(void);
919884
920885 /** Uninitialize the filter system. Unregister all filters. */
@@ -1024,4 +989,6 @@ static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index, · 103 unmodified lines
1024989 &f->output_pads, &f->outputs, p);
1025990 }
1026991
992+#include "audio.h"
993+
1027994 #endif /* AVFILTER_AVFILTER_H */
libavfilter/defaults.c+1−64
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include "libavutil/audioconvert.h"
2424 #include "libavutil/imgutils.h"
2525 #include "libavutil/samplefmt.h"
26+
2627 #include "avfilter.h"
2728 #include "internal.h"
2829
@@ -87,38 +88,6 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per · 58 unmodified lines
8788 return picref;
8889 }
8990
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−
12291 void avfilter_default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
12392 {
12493 AVFilterLink *outlink = NULL;
@@ -163,27 +132,6 @@ void avfilter_default_end_frame(AVFilterLink *inlink) · 38 unmodified lines
163132 }
164133 }
165134
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−
187135 static void set_common_formats(AVFilterContext *ctx, AVFilterFormats *fmts,
188136 enum AVMediaType type, int offin, int offout)
189137 {
@@ -258,18 +206,7 @@ void avfilter_null_end_frame(AVFilterLink *link) · 68 unmodified lines
258206 avfilter_end_frame(link->dst->outputs[0]);
259207 }
260208
261−void avfilter_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
262−{
263− avfilter_filter_samples(link->dst->outputs[0], samplesref);
264−}
265−
266209 AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
267210 {
268211 return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h);
269212 }
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−}
libavfilter/internal.h+6−0
@@ -149,4 +149,10 @@ static inline void ff_null_start_frame_keep_ref(AVFilterLink *inlink, · 148 unmodified lines
149149 avfilter_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0));
150150 }
151151
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+
152158 #endif /* AVFILTER_INTERNAL_H */
libavfilter/src_buffer.c+2−2
@@ -297,7 +297,7 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx, · 296 unmodified lines
297297 break;
298298
299299 case AVMEDIA_TYPE_AUDIO:
300− buf = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE,
300+ buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE,
301301 ref->audio->nb_samples);
302302 channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout);
303303 data_size = av_samples_get_buffer_size(NULL, channels,
@@ -562,7 +562,7 @@ static int request_frame(AVFilterLink *link) · 258 unmodified lines
562562 avfilter_unref_buffer(buf);
563563 break;
564564 case AVMEDIA_TYPE_AUDIO:
565− avfilter_filter_samples(link, avfilter_ref_buffer(buf, ~0));
565+ ff_filter_samples(link, avfilter_ref_buffer(buf, ~0));
566566 avfilter_unref_buffer(buf);
567567 break;
568568 default:
libavfilter/src_movie.c+2−2
@@ -437,7 +437,7 @@ static int amovie_get_samples(AVFilterLink *outlink) · 436 unmodified lines
437437 if (data_size < 0)
438438 return data_size;
439439 movie->samplesref =
440− avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, nb_samples);
440+ ff_get_audio_buffer(outlink, AV_PERM_WRITE, nb_samples);
441441 memcpy(movie->samplesref->data[0], movie->frame->data[0], data_size);
442442 movie->samplesref->pts = movie->pkt.pts;
443443 movie->samplesref->pos = movie->pkt.pos;
@@ -463,7 +463,7 @@ static int amovie_request_frame(AVFilterLink *outlink) · 19 unmodified lines
463463 return ret;
464464 } while (!movie->samplesref);
465465
466− avfilter_filter_samples(outlink, avfilter_ref_buffer(movie->samplesref, ~0));
466+ ff_filter_samples(outlink, avfilter_ref_buffer(movie->samplesref, ~0));
467467 avfilter_unref_buffer(movie->samplesref);
468468 movie->samplesref = NULL;
469469
libavfilter/version.h+3−0
@@ -47,5 +47,8 @@ · 46 unmodified lines
4747 #ifndef FF_API_GRAPH_AVCLASS
4848 #define FF_API_GRAPH_AVCLASS (LIBAVFILTER_VERSION_MAJOR > 2)
4949 #endif
50+#ifndef FF_API_SAMPLERATE64
51+#define FF_API_SAMPLERATE64 (LIBAVFILTER_VERSION_MAJOR < 3)
52+#endif
5053
5154 #endif // AVFILTER_VERSION_H
libavformat/mov.c+1−1
@@ -1051,7 +1051,7 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 1050 unmodified lines
10511051 return AVERROR_INVALIDDATA;
10521052
10531053 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
10551055 // wrap a whole fiel atom inside of a glbl atom.
10561056 unsigned size = avio_rb32(pb);
10571057 unsigned type = avio_rl32(pb);
libavformat/rtmpproto.c+59−13
@@ -44,6 +44,8 @@ · 43 unmodified lines
4444
4545 #define APP_MAX_LENGTH 128
4646 #define PLAYPATH_MAX_LENGTH 256
47+#define TCURL_MAX_LENGTH 512
48+#define FLASHVER_MAX_LENGTH 64
4749
4850 /** RTMP protocol handler state */
4951 typedef enum {
@@ -82,6 +84,9 @@ typedef struct RTMPContext { · 32 unmodified lines
8284 int flv_header_bytes; ///< number of initialized bytes in flv_header
8385 int nb_invokes; ///< keeps track of invoke messages
8486 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
8590 } RTMPContext;
8691
8792 #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
110115 /**
111116 * Generate 'connect' call and send it to the server.
112117 */
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)
115119 {
116120 RTMPPacket pkt;
117− uint8_t ver[64], *p;
118− char tcurl[512];
121+ uint8_t *p;
119122
120123 ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 4096);
121124 p = pkt.data;
122125
123− ff_url_join(tcurl, sizeof(tcurl), proto, NULL, host, port, "/%s", rt->app);
124126 ff_amf_write_string(&p, "connect");
125127 ff_amf_write_number(&p, ++rt->nb_invokes);
126128 ff_amf_write_object_start(&p);
127129 ff_amf_write_field_name(&p, "app");
128130 ff_amf_write_string(&p, rt->app);
129131
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) {
135133 ff_amf_write_field_name(&p, "type");
136134 ff_amf_write_string(&p, "nonprivate");
137135 }
138136 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+
140144 ff_amf_write_field_name(&p, "tcUrl");
141− ff_amf_write_string(&p, tcurl);
145+ ff_amf_write_string(&p, rt->tcurl);
142146 if (rt->is_input) {
143147 ff_amf_write_field_name(&p, "fpad");
144148 ff_amf_write_bool(&p, 0);
@@ -368,6 +372,25 @@ static void gen_server_bw(URLContext *s, RTMPContext *rt) · 223 unmodified lines
368372 ff_rtmp_packet_destroy(&pkt);
369373 }
370374
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+
371394 /**
372395 * Generate report on bytes read so far and send it to the server.
373396 */
@@ -687,6 +710,8 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) · 313 unmodified lines
687710 if (!t && !strcmp(tmpstr, "NetStream.Play.Stop")) rt->state = STATE_STOPPED;
688711 if (!t && !strcmp(tmpstr, "NetStream.Play.UnpublishNotify")) rt->state = STATE_STOPPED;
689712 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);
690715 }
691716 break;
692717 }
@@ -910,13 +935,31 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) · 217 unmodified lines
910935 strncat(rt->playpath, fname, PLAYPATH_MAX_LENGTH - 5);
911936 }
912937
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+
913956 rt->client_report_size = 1048576;
914957 rt->bytes_read = 0;
915958 rt->last_bytes_read = 0;
916959
917960 av_log(s, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n",
918961 proto, path, rt->app, rt->playpath);
919− gen_connect(s, rt, proto, hostname, port);
962+ gen_connect(s, rt);
920963
921964 do {
922965 ret = get_packet(s, 1);
@@ -1052,11 +1095,14 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size) · 129 unmodified lines
10521095
10531096 static const AVOption rtmp_options[] = {
10541097 {"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},
10551099 {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), AV_OPT_TYPE_INT, {-2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},
10561100 {"any", "both", 0, AV_OPT_TYPE_CONST, {-2}, 0, 0, DEC, "rtmp_live"},
10571101 {"live", "live stream", 0, AV_OPT_TYPE_CONST, {-1}, 0, 0, DEC, "rtmp_live"},
10581102 {"recorded", "recorded stream", 0, AV_OPT_TYPE_CONST, {0}, 0, 0, DEC, "rtmp_live"},
10591103 {"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},
10601106 { NULL },
10611107 };
10621108
libavformat/sctp.c+1−1
@@ -227,7 +227,7 @@ static int sctp_open(URLContext *h, const char *uri, int flags) · 226 unmodified lines
227227 if (s->max_streams) {
228228 initparams.sinit_max_instreams = s->max_streams;
229229 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,
231231 sizeof(initparams)) < 0)
232232 av_log(h, AV_LOG_ERROR,
233233 "SCTP ERROR: Unable to initialize socket max streams %d\n",
libavresample/x86/audio_convert.asm+16−14
@@ -54,26 +54,24 @@ cglobal conv_fltp_to_flt_6ch, 2,8,7, dst, src, src1, src2, src3, src4, src5, len · 53 unmodified lines
5454 mova m3, [srcq+src3q]
5555 mova m4, [srcq+src4q]
5656 mova m5, [srcq+src5q]
57−%if cpuflag(sse)
57+%if cpuflag(sse4)
5858 SBUTTERFLYPS 0, 1, 6
5959 SBUTTERFLYPS 2, 3, 6
6060 SBUTTERFLYPS 4, 5, 6
6161
62− movaps m6, m4
63− shufps m4, m0, q3210
62+ blendps m6, m4, m0, 1100b
6463 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
7266 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
7472 movaps [dstq+48], m1
75− movaps [dstq+64], m5
76− movaps [dstq+80], m6
73+ movaps [dstq+64], m2
74+ movaps [dstq+80], m5
7775 %else ; mmx
7876 SBUTTERFLY dq, 0, 1, 6
7977 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
10098
10199 INIT_MMX mmx
102100 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
104105 CONV_FLTP_TO_FLT_6CH
106+%endif
libavresample/x86/audio_convert_init.c+9−4
@@ -22,8 +22,9 @@ · 21 unmodified lines
2222 #include "libavutil/cpu.h"
2323 #include "libavresample/audio_convert.h"
2424
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);
2728
2829 av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
2930 {
@@ -34,9 +35,13 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac) · 4 unmodified lines
3435 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
3536 6, 1, 4, "MMX", ff_conv_fltp_to_flt_6ch_mmx);
3637 }
37− if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) {
38+ if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) {
3839 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);
4045 }
4146 #endif
4247 }
libavutil/x86/x86util.asm+3−4
@@ -42,10 +42,9 @@ · 41 unmodified lines
4242 %endmacro
4343
4444 %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
4948 %endmacro
5049
5150 %macro TRANSPOSE4x4B 5

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

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

Repository code

Go to file
t