* qatar/master: (28 commits) Replace usages of av_get_bits_per_sample_fmt() with av_get_bytes_per_sample(). x86: cabac: fix register constraints for 32-bit mode cabac: move x86 asm to libavcodec/x86/cabac.h x86: h264: cast pointers to intptr_t rather than int x86: h264: remove hardcoded edi in decode_significance_8x8_x86() x86: h264: remove hardcoded esi in decode_significance[_8x8]_x86() x86: h264: remove hardcoded edx in decode_significance[_8x8]_x86() x86: h264: remove hardcoded eax in decode_significance[_8x8]_x86() x86: cabac: change 'a' constraint to 'r' in get_cabac_inline() x86: cabac: remove hardcoded esi in get_cabac_inline() x86: cabac: remove hardcoded edx in get_cabac_inline() x86: cabac: remove unused macro parameter x86: cabac: remove hardcoded ebx in inline asm x86: cabac: remove hardcoded struct offsets from inline asm cabac: remove inline asm under #if 0 cabac: remove BRANCHLESS_CABAC_DECODER switch cabac: remove #if 0 cascade under never-set #ifdef ARCH_X86_DISABLED document libswscale bump error_resilience: skip last-MV predictor step if MVs are not available. error_resilience: actually add counter when adding a MV predictor. ... Conflicts: Changelog libavcodec/error_resilience.c libavfilter/defaults.c libavfilter/vf_drawtext.c libswscale/swscale.h tests/ref/vsynth1/error tests/ref/vsynth2/error
Unified · Split
| @@ -18,6 +18,7 @@ version 0.7: · 17 unmodified lines | ||
| 18 | 18 | - 10-bit H.264 optimizations for x86 |
| 19 | 19 | - lut, lutrgb, and lutyuv filters added |
| 20 | 20 | - buffersink libavfilter sink added |
| 21 | +- Bump libswscale for recently reported ABI break | |
| 21 | 22 | |
| 22 | 23 | |
| 23 | 24 | version 0.7_beta2: |
| @@ -7,7 +7,7 @@ libavdevice: 2011-04-18 · 6 unmodified lines | ||
| 7 | 7 | libavfilter: 2011-04-18 |
| 8 | 8 | libavformat: 2011-04-18 |
| 9 | 9 | libpostproc: 2011-04-18 |
| 10 | −libswscale: 2011-04-18 | |
| 10 | +libswscale: 2011-06-20 | |
| 11 | 11 | libavutil: 2011-04-18 |
| 12 | 12 | |
| 13 | 13 | |
| @@ -810,8 +810,8 @@ static void do_audio_out(AVFormatContext *s, · 809 unmodified lines | ||
| 810 | 810 | int size_out, frame_bytes, ret, resample_changed; |
| 811 | 811 | AVCodecContext *enc= ost->st->codec; |
| 812 | 812 | AVCodecContext *dec= ist->st->codec; |
| 813 | − int osize= av_get_bits_per_sample_fmt(enc->sample_fmt)/8; | |
| 814 | − int isize= av_get_bits_per_sample_fmt(dec->sample_fmt)/8; | |
| 813 | + int osize = av_get_bytes_per_sample(enc->sample_fmt); | |
| 814 | + int isize = av_get_bytes_per_sample(dec->sample_fmt); | |
| 815 | 815 | const int coded_bps = av_get_bits_per_sample(enc->codec->id); |
| 816 | 816 | |
| 817 | 817 | need_realloc: |
| @@ -1531,7 +1531,7 @@ static int output_packet(AVInputStream *ist, int ist_index, · 713 unmodified lines | ||
| 1531 | 1531 | #endif |
| 1532 | 1532 | |
| 1533 | 1533 | AVPacket avpkt; |
| 1534 | − int bps = av_get_bits_per_sample_fmt(ist->st->codec->sample_fmt)>>3; | |
| 1534 | + int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt); | |
| 1535 | 1535 | |
| 1536 | 1536 | if(ist->next_pts == AV_NOPTS_VALUE) |
| 1537 | 1537 | ist->next_pts= ist->pts; |
| @@ -2010,7 +2010,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) · 2009 unmodified lines | ||
| 2010 | 2010 | if (is->reformat_ctx) { |
| 2011 | 2011 | const void *ibuf[6]= {is->audio_buf1}; |
| 2012 | 2012 | void *obuf[6]= {is->audio_buf2}; |
| 2013 | − int istride[6]= {av_get_bits_per_sample_fmt(dec->sample_fmt)/8}; | |
| 2013 | + int istride[6]= {av_get_bytes_per_sample(dec->sample_fmt)}; | |
| 2014 | 2014 | int ostride[6]= {2}; |
| 2015 | 2015 | int len= data_size/istride[0]; |
| 2016 | 2016 | if (av_audio_convert(is->reformat_ctx, obuf, ostride, ibuf, istride, len)<0) { |
| @@ -2179,7 +2179,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, · 2178 unmodified lines | ||
| 2179 | 2179 | } |
| 2180 | 2180 | |
| 2181 | 2181 | data_size_tmp = samples * avctx->channels * |
| 2182 | − (av_get_bits_per_sample_fmt(avctx->sample_fmt) / 8); | |
| 2182 | + av_get_bytes_per_sample(avctx->sample_fmt); | |
| 2183 | 2183 | if (*data_size < data_size_tmp) { |
| 2184 | 2184 | av_log(avctx, AV_LOG_ERROR, |
| 2185 | 2185 | "Output buffer too small (%d) or trying to output too many samples (%d) for this frame.\n", |
| @@ -1422,7 +1422,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 1421 unmodified lines | ||
| 1422 | 1422 | } |
| 1423 | 1423 | } |
| 1424 | 1424 | *data_size = s->num_blocks * 256 * avctx->channels * |
| 1425 | − (av_get_bits_per_sample_fmt(avctx->sample_fmt) / 8); | |
| 1425 | + av_get_bytes_per_sample(avctx->sample_fmt); | |
| 1426 | 1426 | return FFMIN(buf_size, s->frame_size); |
| 1427 | 1427 | } |
| 1428 | 1428 | |
| @@ -1450,7 +1450,7 @@ static int decode_frame(AVCodecContext *avctx, · 1449 unmodified lines | ||
| 1450 | 1450 | |
| 1451 | 1451 | // check for size of decoded data |
| 1452 | 1452 | size = ctx->cur_frame_length * avctx->channels * |
| 1453 | − (av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3); | |
| 1453 | + av_get_bytes_per_sample(avctx->sample_fmt); | |
| 1454 | 1454 | |
| 1455 | 1455 | if (size > *data_size) { |
| 1456 | 1456 | av_log(avctx, AV_LOG_ERROR, "Decoded data exceeds buffer size.\n"); |
| @@ -1714,7 +1714,7 @@ static av_cold int decode_init(AVCodecContext *avctx) · 257 unmodified lines | ||
| 1714 | 1714 | ctx->crc_buffer = av_malloc(sizeof(*ctx->crc_buffer) * |
| 1715 | 1715 | ctx->cur_frame_length * |
| 1716 | 1716 | avctx->channels * |
| 1717 | − (av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3)); | |
| 1717 | + av_get_bytes_per_sample(avctx->sample_fmt)); | |
| 1718 | 1718 | if (!ctx->crc_buffer) { |
| 1719 | 1719 | av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); |
| 1720 | 1720 | decode_end(avctx); |
| @@ -161,19 +161,11 @@ void ff_init_cabac_states(CABACContext *c){ · 160 unmodified lines | ||
| 161 | 161 | ff_h264_mps_state[2*i+1]= 2*mps_state[i]+1; |
| 162 | 162 | |
| 163 | 163 | if( i ){ |
| 164 | −#ifdef BRANCHLESS_CABAC_DECODER | |
| 165 | 164 | ff_h264_mlps_state[128-2*i-1]= 2*lps_state[i]+0; |
| 166 | 165 | ff_h264_mlps_state[128-2*i-2]= 2*lps_state[i]+1; |
| 167 | 166 | }else{ |
| 168 | 167 | ff_h264_mlps_state[128-2*i-1]= 1; |
| 169 | 168 | ff_h264_mlps_state[128-2*i-2]= 0; |
| 170 | −#else | |
| 171 | − ff_h264_lps_state[2*i+0]= 2*lps_state[i]+0; | |
| 172 | − ff_h264_lps_state[2*i+1]= 2*lps_state[i]+1; | |
| 173 | − }else{ | |
| 174 | − ff_h264_lps_state[2*i+0]= 1; | |
| 175 | − ff_h264_lps_state[2*i+1]= 0; | |
| 176 | −#endif | |
| 177 | 169 | } |
| 178 | 170 | } |
| 179 | 171 | } |
| @@ -27,16 +27,15 @@ · 26 unmodified lines | ||
| 27 | 27 | #ifndef AVCODEC_CABAC_H |
| 28 | 28 | #define AVCODEC_CABAC_H |
| 29 | 29 | |
| 30 | +#include <stddef.h> | |
| 31 | + | |
| 30 | 32 | #include "put_bits.h" |
| 31 | 33 | |
| 32 | 34 | //#undef NDEBUG |
| 33 | 35 | #include <assert.h> |
| 34 | −#include "libavutil/x86_cpu.h" | |
| 35 | 36 | |
| 36 | 37 | #define CABAC_BITS 16 |
| 37 | 38 | #define CABAC_MASK ((1<<CABAC_BITS)-1) |
| 38 | −#define BRANCHLESS_CABAC_DECODER 1 | |
| 39 | −//#define ARCH_X86_DISABLED 1 | |
| 40 | 39 | |
| 41 | 40 | typedef struct CABACContext{ |
| 42 | 41 | int low; |
| @@ -57,6 +56,9 @@ extern uint8_t ff_h264_mps_state[2*64]; ///< transIdxMPS · 14 unmodified lines | ||
| 57 | 56 | extern uint8_t ff_h264_lps_state[2*64]; ///< transIdxLPS |
| 58 | 57 | extern const uint8_t ff_h264_norm_shift[512]; |
| 59 | 58 | |
| 59 | +#if ARCH_X86 | |
| 60 | +# include "x86/cabac.h" | |
| 61 | +#endif | |
| 60 | 62 | |
| 61 | 63 | void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size); |
| 62 | 64 | void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size); |
| @@ -270,26 +272,6 @@ static void refill(CABACContext *c){ · 207 unmodified lines | ||
| 270 | 272 | c->bytestream+= CABAC_BITS/8; |
| 271 | 273 | } |
| 272 | 274 | |
| 273 | −#if ! ( ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) ) | |
| 274 | −static void refill2(CABACContext *c){ | |
| 275 | − int i, x; | |
| 276 | − | |
| 277 | − x= c->low ^ (c->low-1); | |
| 278 | − i= 7 - ff_h264_norm_shift[x>>(CABAC_BITS-1)]; | |
| 279 | − | |
| 280 | − x= -CABAC_MASK; | |
| 281 | − | |
| 282 | −#if CABAC_BITS == 16 | |
| 283 | − x+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1); | |
| 284 | −#else | |
| 285 | − x+= c->bytestream[0]<<1; | |
| 286 | −#endif | |
| 287 | − | |
| 288 | − c->low += x<<i; | |
| 289 | − c->bytestream+= CABAC_BITS/8; | |
| 290 | −} | |
| 291 | −#endif | |
| 292 | − | |
| 293 | 275 | static inline void renorm_cabac_decoder(CABACContext *c){ |
| 294 | 276 | while(c->range < 0x100){ |
| 295 | 277 | c->range+= c->range; |
| @@ -300,267 +282,38 @@ static inline void renorm_cabac_decoder(CABACContext *c){ · 4 unmodified lines | ||
| 300 | 282 | } |
| 301 | 283 | |
| 302 | 284 | static inline void renorm_cabac_decoder_once(CABACContext *c){ |
| 303 | −#ifdef ARCH_X86_DISABLED | |
| 304 | − int temp; | |
| 305 | −#if 0 | |
| 306 | − //P3:683 athlon:475 | |
| 307 | − __asm__( | |
| 308 | − "lea -0x100(%0), %2 \n\t" | |
| 309 | − "shr $31, %2 \n\t" //FIXME 31->63 for x86-64 | |
| 310 | − "shl %%cl, %0 \n\t" | |
| 311 | − "shl %%cl, %1 \n\t" | |
| 312 | − : "+r"(c->range), "+r"(c->low), "+c"(temp) | |
| 313 | − ); | |
| 314 | −#elif 0 | |
| 315 | − //P3:680 athlon:474 | |
| 316 | − __asm__( | |
| 317 | − "cmp $0x100, %0 \n\t" | |
| 318 | − "setb %%cl \n\t" //FIXME 31->63 for x86-64 | |
| 319 | − "shl %%cl, %0 \n\t" | |
| 320 | − "shl %%cl, %1 \n\t" | |
| 321 | − : "+r"(c->range), "+r"(c->low), "+c"(temp) | |
| 322 | − ); | |
| 323 | −#elif 1 | |
| 324 | − int temp2; | |
| 325 | − //P3:665 athlon:517 | |
| 326 | − __asm__( | |
| 327 | − "lea -0x100(%0), %%eax \n\t" | |
| 328 | − "cltd \n\t" | |
| 329 | − "mov %0, %%eax \n\t" | |
| 330 | − "and %%edx, %0 \n\t" | |
| 331 | − "and %1, %%edx \n\t" | |
| 332 | − "add %%eax, %0 \n\t" | |
| 333 | − "add %%edx, %1 \n\t" | |
| 334 | − : "+r"(c->range), "+r"(c->low), "+a"(temp), "+d"(temp2) | |
| 335 | − ); | |
| 336 | −#elif 0 | |
| 337 | − int temp2; | |
| 338 | − //P3:673 athlon:509 | |
| 339 | − __asm__( | |
| 340 | − "cmp $0x100, %0 \n\t" | |
| 341 | − "sbb %%edx, %%edx \n\t" | |
| 342 | − "mov %0, %%eax \n\t" | |
| 343 | − "and %%edx, %0 \n\t" | |
| 344 | − "and %1, %%edx \n\t" | |
| 345 | − "add %%eax, %0 \n\t" | |
| 346 | − "add %%edx, %1 \n\t" | |
| 347 | − : "+r"(c->range), "+r"(c->low), "+a"(temp), "+d"(temp2) | |
| 348 | − ); | |
| 349 | −#else | |
| 350 | − int temp2; | |
| 351 | − //P3:677 athlon:511 | |
| 352 | − __asm__( | |
| 353 | − "cmp $0x100, %0 \n\t" | |
| 354 | − "lea (%0, %0), %%eax \n\t" | |
| 355 | − "lea (%1, %1), %%edx \n\t" | |
| 356 | − "cmovb %%eax, %0 \n\t" | |
| 357 | − "cmovb %%edx, %1 \n\t" | |
| 358 | − : "+r"(c->range), "+r"(c->low), "+a"(temp), "+d"(temp2) | |
| 359 | − ); | |
| 360 | −#endif | |
| 361 | −#else | |
| 362 | − //P3:675 athlon:476 | |
| 363 | 285 | int shift= (uint32_t)(c->range - 0x100)>>31; |
| 364 | 286 | c->range<<= shift; |
| 365 | 287 | c->low <<= shift; |
| 366 | −#endif | |
| 367 | 288 | if(!(c->low & CABAC_MASK)) |
| 368 | 289 | refill(c); |
| 369 | 290 | } |
| 370 | 291 | |
| 371 | −static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){ | |
| 372 | − //FIXME gcc generates duplicate load/stores for c->low and c->range | |
| 373 | −#define LOW "0" | |
| 374 | −#define RANGE "4" | |
| 375 | −#if ARCH_X86_64 | |
| 376 | −#define BYTESTART "16" | |
| 377 | −#define BYTE "24" | |
| 378 | −#define BYTEEND "32" | |
| 379 | −#else | |
| 380 | −#define BYTESTART "12" | |
| 381 | −#define BYTE "16" | |
| 382 | −#define BYTEEND "20" | |
| 383 | −#endif | |
| 384 | −#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) | |
| 385 | − int bit; | |
| 386 | − | |
| 387 | −#ifndef BRANCHLESS_CABAC_DECODER | |
| 388 | − __asm__ volatile( | |
| 389 | − "movzbl (%1), %0 \n\t" | |
| 390 | − "movl "RANGE "(%2), %%ebx \n\t" | |
| 391 | − "movl "RANGE "(%2), %%edx \n\t" | |
| 392 | − "andl $0xC0, %%ebx \n\t" | |
| 393 | − "movzbl "MANGLE(ff_h264_lps_range)"(%0, %%ebx, 2), %%esi\n\t" | |
| 394 | − "movl "LOW "(%2), %%ebx \n\t" | |
| 395 | −//eax:state ebx:low, edx:range, esi:RangeLPS | |
| 396 | − "subl %%esi, %%edx \n\t" | |
| 397 | − "movl %%edx, %%ecx \n\t" | |
| 398 | − "shll $17, %%ecx \n\t" | |
| 399 | − "cmpl %%ecx, %%ebx \n\t" | |
| 400 | − " ja 1f \n\t" | |
| 292 | +#ifndef get_cabac_inline | |
| 293 | +static void refill2(CABACContext *c){ | |
| 294 | + int i, x; | |
| 401 | 295 | |
| 402 | −#if 1 | |
| 403 | − //athlon:4067 P3:4110 | |
| 404 | − "lea -0x100(%%edx), %%ecx \n\t" | |
| 405 | − "shr $31, %%ecx \n\t" | |
| 406 | − "shl %%cl, %%edx \n\t" | |
| 407 | − "shl %%cl, %%ebx \n\t" | |
| 296 | + x= c->low ^ (c->low-1); | |
| 297 | + i= 7 - ff_h264_norm_shift[x>>(CABAC_BITS-1)]; | |
| 298 | + | |
| 299 | + x= -CABAC_MASK; | |
| 300 | + | |
| 301 | +#if CABAC_BITS == 16 | |
| 302 | + x+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1); | |
| 408 | 303 | #else |
| 409 | − //athlon:4057 P3:4130 | |
| 410 | − "cmp $0x100, %%edx \n\t" //FIXME avoidable | |
| 411 | − "setb %%cl \n\t" | |
| 412 | − "shl %%cl, %%edx \n\t" | |
| 413 | − "shl %%cl, %%ebx \n\t" | |
| 304 | + x+= c->bytestream[0]<<1; | |
| 414 | 305 | #endif |
| 415 | − "movzbl "MANGLE(ff_h264_mps_state)"(%0), %%ecx \n\t" | |
| 416 | − "movb %%cl, (%1) \n\t" | |
| 417 | −//eax:state ebx:low, edx:range, esi:RangeLPS | |
| 418 | − "test %%bx, %%bx \n\t" | |
| 419 | − " jnz 2f \n\t" | |
| 420 | − "mov "BYTE "(%2), %%"REG_S" \n\t" | |
| 421 | − "subl $0xFFFF, %%ebx \n\t" | |
| 422 | − "movzwl (%%"REG_S"), %%ecx \n\t" | |
| 423 | − "bswap %%ecx \n\t" | |
| 424 | − "shrl $15, %%ecx \n\t" | |
| 425 | − "add $2, %%"REG_S" \n\t" | |
| 426 | − "addl %%ecx, %%ebx \n\t" | |
| 427 | − "mov %%"REG_S", "BYTE "(%2) \n\t" | |
| 428 | − "jmp 2f \n\t" | |
| 429 | − "1: \n\t" | |
| 430 | −//eax:state ebx:low, edx:range, esi:RangeLPS | |
| 431 | − "subl %%ecx, %%ebx \n\t" | |
| 432 | − "movl %%esi, %%edx \n\t" | |
| 433 | − "movzbl " MANGLE(ff_h264_norm_shift) "(%%esi), %%ecx \n\t" | |
| 434 | − "shll %%cl, %%ebx \n\t" | |
| 435 | − "shll %%cl, %%edx \n\t" | |
| 436 | − "movzbl "MANGLE(ff_h264_lps_state)"(%0), %%ecx \n\t" | |
| 437 | − "movb %%cl, (%1) \n\t" | |
| 438 | − "add $1, %0 \n\t" | |
| 439 | − "test %%bx, %%bx \n\t" | |
| 440 | − " jnz 2f \n\t" | |
| 441 | − | |
| 442 | − "mov "BYTE "(%2), %%"REG_c" \n\t" | |
| 443 | − "movzwl (%%"REG_c"), %%esi \n\t" | |
| 444 | − "bswap %%esi \n\t" | |
| 445 | − "shrl $15, %%esi \n\t" | |
| 446 | − "subl $0xFFFF, %%esi \n\t" | |
| 447 | − "add $2, %%"REG_c" \n\t" | |
| 448 | − "mov %%"REG_c", "BYTE "(%2) \n\t" | |
| 449 | − | |
| 450 | − "leal -1(%%ebx), %%ecx \n\t" | |
| 451 | − "xorl %%ebx, %%ecx \n\t" | |
| 452 | − "shrl $15, %%ecx \n\t" | |
| 453 | − "movzbl " MANGLE(ff_h264_norm_shift) "(%%ecx), %%ecx \n\t" | |
| 454 | − "neg %%ecx \n\t" | |
| 455 | − "add $7, %%ecx \n\t" | |
| 456 | − | |
| 457 | − "shll %%cl , %%esi \n\t" | |
| 458 | − "addl %%esi, %%ebx \n\t" | |
| 459 | − "2: \n\t" | |
| 460 | − "movl %%edx, "RANGE "(%2) \n\t" | |
| 461 | − "movl %%ebx, "LOW "(%2) \n\t" | |
| 462 | − :"=&a"(bit) //FIXME this is fragile gcc either runs out of registers or miscompiles it (for example if "+a"(bit) or "+m"(*state) is used | |
| 463 | − :"r"(state), "r"(c) | |
| 464 | − : "%"REG_c, "%ebx", "%edx", "%"REG_S, "memory" | |
| 465 | − ); | |
| 466 | − bit&=1; | |
| 467 | −#else /* BRANCHLESS_CABAC_DECODER */ | |
| 468 | − | |
| 469 | − | |
| 470 | −#if HAVE_FAST_CMOV | |
| 471 | −#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\ | |
| 472 | − "mov "tmp" , %%ecx \n\t"\ | |
| 473 | − "shl $17 , "tmp" \n\t"\ | |
| 474 | − "cmp "low" , "tmp" \n\t"\ | |
| 475 | − "cmova %%ecx , "range" \n\t"\ | |
| 476 | − "sbb %%ecx , %%ecx \n\t"\ | |
| 477 | − "and %%ecx , "tmp" \n\t"\ | |
| 478 | − "sub "tmp" , "low" \n\t"\ | |
| 479 | − "xor %%ecx , "ret" \n\t" | |
| 480 | −#else /* HAVE_FAST_CMOV */ | |
| 481 | −#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\ | |
| 482 | − "mov "tmp" , %%ecx \n\t"\ | |
| 483 | − "shl $17 , "tmp" \n\t"\ | |
| 484 | − "sub "low" , "tmp" \n\t"\ | |
| 485 | − "sar $31 , "tmp" \n\t" /*lps_mask*/\ | |
| 486 | − "sub %%ecx , "range" \n\t" /*RangeLPS - range*/\ | |
| 487 | − "and "tmp" , "range" \n\t" /*(RangeLPS - range)&lps_mask*/\ | |
| 488 | − "add %%ecx , "range" \n\t" /*new range*/\ | |
| 489 | − "shl $17 , %%ecx \n\t"\ | |
| 490 | − "and "tmp" , %%ecx \n\t"\ | |
| 491 | − "sub %%ecx , "low" \n\t"\ | |
| 492 | − "xor "tmp" , "ret" \n\t" | |
| 493 | −#endif /* HAVE_FAST_CMOV */ | |
| 494 | − | |
| 495 | − | |
| 496 | −#define BRANCHLESS_GET_CABAC(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\ | |
| 497 | − "movzbl "statep" , "ret" \n\t"\ | |
| 498 | − "mov "range" , "tmp" \n\t"\ | |
| 499 | − "and $0xC0 , "range" \n\t"\ | |
| 500 | − "movzbl "MANGLE(ff_h264_lps_range)"("ret", "range", 2), "range" \n\t"\ | |
| 501 | − "sub "range" , "tmp" \n\t"\ | |
| 502 | − BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\ | |
| 503 | − "movzbl " MANGLE(ff_h264_norm_shift) "("range"), %%ecx \n\t"\ | |
| 504 | − "shl %%cl , "range" \n\t"\ | |
| 505 | − "movzbl "MANGLE(ff_h264_mlps_state)"+128("ret"), "tmp" \n\t"\ | |
| 506 | − "mov "tmpbyte" , "statep" \n\t"\ | |
| 507 | − "shl %%cl , "low" \n\t"\ | |
| 508 | − "test "lowword" , "lowword" \n\t"\ | |
| 509 | − " jnz 1f \n\t"\ | |
| 510 | − "mov "BYTE"("cabac"), %%"REG_c" \n\t"\ | |
| 511 | − "movzwl (%%"REG_c") , "tmp" \n\t"\ | |
| 512 | − "bswap "tmp" \n\t"\ | |
| 513 | − "shr $15 , "tmp" \n\t"\ | |
| 514 | − "sub $0xFFFF , "tmp" \n\t"\ | |
| 515 | − "add $2 , %%"REG_c" \n\t"\ | |
| 516 | − "mov %%"REG_c" , "BYTE "("cabac") \n\t"\ | |
| 517 | − "lea -1("low") , %%ecx \n\t"\ | |
| 518 | − "xor "low" , %%ecx \n\t"\ | |
| 519 | − "shr $15 , %%ecx \n\t"\ | |
| 520 | − "movzbl " MANGLE(ff_h264_norm_shift) "(%%ecx), %%ecx \n\t"\ | |
| 521 | − "neg %%ecx \n\t"\ | |
| 522 | − "add $7 , %%ecx \n\t"\ | |
| 523 | − "shl %%cl , "tmp" \n\t"\ | |
| 524 | − "add "tmp" , "low" \n\t"\ | |
| 525 | − "1: \n\t" | |
| 526 | − | |
| 527 | − __asm__ volatile( | |
| 528 | − "movl "RANGE "(%2), %%esi \n\t" | |
| 529 | − "movl "LOW "(%2), %%ebx \n\t" | |
| 530 | − BRANCHLESS_GET_CABAC("%0", "%2", "(%1)", "%%ebx", "%%bx", "%%esi", "%%edx", "%%dl") | |
| 531 | − "movl %%esi, "RANGE "(%2) \n\t" | |
| 532 | − "movl %%ebx, "LOW "(%2) \n\t" | |
| 533 | − | |
| 534 | − :"=&a"(bit) | |
| 535 | − :"r"(state), "r"(c) | |
| 536 | − : "%"REG_c, "%ebx", "%edx", "%esi", "memory" | |
| 537 | − ); | |
| 538 | − bit&=1; | |
| 539 | −#endif /* BRANCHLESS_CABAC_DECODER */ | |
| 540 | −#else /* ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) */ | |
| 306 | + | |
| 307 | + c->low += x<<i; | |
| 308 | + c->bytestream+= CABAC_BITS/8; | |
| 309 | +} | |
| 310 | + | |
| 311 | +static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){ | |
| 541 | 312 | int s = *state; |
| 542 | 313 | int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + s]; |
| 543 | − int bit, lps_mask av_unused; | |
| 314 | + int bit, lps_mask; | |
| 544 | 315 | |
| 545 | 316 | c->range -= RangeLPS; |
| 546 | −#ifndef BRANCHLESS_CABAC_DECODER | |
| 547 | − if(c->low < (c->range<<(CABAC_BITS+1))){ | |
| 548 | − bit= s&1; | |
| 549 | − *state= ff_h264_mps_state[s]; | |
| 550 | − renorm_cabac_decoder_once(c); | |
| 551 | − }else{ | |
| 552 | − bit= ff_h264_norm_shift[RangeLPS]; | |
| 553 | − c->low -= (c->range<<(CABAC_BITS+1)); | |
| 554 | − *state= ff_h264_lps_state[s]; | |
| 555 | − c->range = RangeLPS<<bit; | |
| 556 | − c->low <<= bit; | |
| 557 | − bit= (s&1)^1; | |
| 558 | − | |
| 559 | − if(!(c->low & CABAC_MASK)){ | |
| 560 | − refill2(c); | |
| 561 | − } | |
| 562 | − } | |
| 563 | −#else /* BRANCHLESS_CABAC_DECODER */ | |
| 564 | 317 | lps_mask= ((c->range<<(CABAC_BITS+1)) - c->low)>>31; |
| 565 | 318 | |
| 566 | 319 | c->low -= (c->range<<(CABAC_BITS+1)) & lps_mask; |
| @@ -575,10 +328,9 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st · 8 unmodified lines | ||
| 575 | 328 | c->low <<= lps_mask; |
| 576 | 329 | if(!(c->low & CABAC_MASK)) |
| 577 | 330 | refill2(c); |
| 578 | −#endif /* BRANCHLESS_CABAC_DECODER */ | |
| 579 | −#endif /* ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) */ | |
| 580 | 331 | return bit; |
| 581 | 332 | } |
| 333 | +#endif | |
| 582 | 334 | |
| 583 | 335 | static int av_noinline av_unused get_cabac_noinline(CABACContext *c, uint8_t * const state){ |
| 584 | 336 | return get_cabac_inline(c,state); |
| @@ -589,36 +341,6 @@ static int av_unused get_cabac(CABACContext *c, uint8_t * const state){ · 4 unmodified lines | ||
| 589 | 341 | } |
| 590 | 342 | |
| 591 | 343 | static int av_unused get_cabac_bypass(CABACContext *c){ |
| 592 | −#if 0 //not faster | |
| 593 | − int bit; | |
| 594 | − __asm__ volatile( | |
| 595 | − "movl "RANGE "(%1), %%ebx \n\t" | |
| 596 | − "movl "LOW "(%1), %%eax \n\t" | |
| 597 | − "shl $17, %%ebx \n\t" | |
| 598 | − "add %%eax, %%eax \n\t" | |
| 599 | − "sub %%ebx, %%eax \n\t" | |
| 600 | − "cltd \n\t" | |
| 601 | − "and %%edx, %%ebx \n\t" | |
| 602 | − "add %%ebx, %%eax \n\t" | |
| 603 | − "test %%ax, %%ax \n\t" | |
| 604 | − " jnz 1f \n\t" | |
| 605 | − "movl "BYTE "(%1), %%"REG_b" \n\t" | |
| 606 | − "subl $0xFFFF, %%eax \n\t" | |
| 607 | − "movzwl (%%"REG_b"), %%ecx \n\t" | |
| 608 | − "bswap %%ecx \n\t" | |
| 609 | − "shrl $15, %%ecx \n\t" | |
| 610 | − "addl $2, %%"REG_b" \n\t" | |
| 611 | − "addl %%ecx, %%eax \n\t" | |
| 612 | − "movl %%"REG_b", "BYTE "(%1) \n\t" | |
| 613 | − "1: \n\t" | |
| 614 | − "movl %%eax, "LOW "(%1) \n\t" | |
| 615 | − | |
| 616 | − :"=&d"(bit) | |
| 617 | − :"r"(c) | |
| 618 | − : "%eax", "%"REG_b, "%ecx", "memory" | |
| 619 | − ); | |
| 620 | − return bit+1; | |
| 621 | −#else | |
| 622 | 344 | int range; |
| 623 | 345 | c->low += c->low; |
| 624 | 346 | |
| @@ -632,42 +354,11 @@ static int av_unused get_cabac_bypass(CABACContext *c){ · 7 unmodified lines | ||
| 632 | 354 | c->low -= range; |
| 633 | 355 | return 1; |
| 634 | 356 | } |
| 635 | −#endif | |
| 636 | 357 | } |
| 637 | 358 | |
| 638 | 359 | |
| 360 | +#ifndef get_cabac_bypass_sign | |
| 639 | 361 | static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){ |
| 640 | −#if ARCH_X86 && HAVE_EBX_AVAILABLE | |
| 641 | − __asm__ volatile( | |
| 642 | − "movl "RANGE "(%1), %%ebx \n\t" | |
| 643 | − "movl "LOW "(%1), %%eax \n\t" | |
| 644 | − "shl $17, %%ebx \n\t" | |
| 645 | − "add %%eax, %%eax \n\t" | |
| 646 | − "sub %%ebx, %%eax \n\t" | |
| 647 | − "cltd \n\t" | |
| 648 | − "and %%edx, %%ebx \n\t" | |
| 649 | − "add %%ebx, %%eax \n\t" | |
| 650 | − "xor %%edx, %%ecx \n\t" | |
| 651 | − "sub %%edx, %%ecx \n\t" | |
| 652 | − "test %%ax, %%ax \n\t" | |
| 653 | − " jnz 1f \n\t" | |
| 654 | − "mov "BYTE "(%1), %%"REG_b" \n\t" | |
| 655 | − "subl $0xFFFF, %%eax \n\t" | |
| 656 | − "movzwl (%%"REG_b"), %%edx \n\t" | |
| 657 | − "bswap %%edx \n\t" | |
| 658 | − "shrl $15, %%edx \n\t" | |
| 659 | − "add $2, %%"REG_b" \n\t" | |
| 660 | − "addl %%edx, %%eax \n\t" | |
| 661 | − "mov %%"REG_b", "BYTE "(%1) \n\t" | |
| 662 | − "1: \n\t" | |
| 663 | − "movl %%eax, "LOW "(%1) \n\t" | |
| 664 | − | |
| 665 | − :"+c"(val) | |
| 666 | − :"r"(c) | |
| 667 | − : "%eax", "%"REG_b, "%edx", "memory" | |
| 668 | − ); | |
| 669 | − return val; | |
| 670 | −#else | |
| 671 | 362 | int range, mask; |
| 672 | 363 | c->low += c->low; |
| 673 | 364 | |
| @@ -680,8 +371,8 @@ static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){ · 6 unmodified lines | ||
| 680 | 371 | range &= mask; |
| 681 | 372 | c->low += range; |
| 682 | 373 | return (val^mask)-mask; |
| 683 | −#endif | |
| 684 | 374 | } |
| 375 | +#endif | |
| 685 | 376 | |
| 686 | 377 | /** |
| 687 | 378 | * |
| @@ -1817,7 +1817,7 @@ static int dca_decode_frame(AVCodecContext * avctx, · 1816 unmodified lines | ||
| 1817 | 1817 | } |
| 1818 | 1818 | |
| 1819 | 1819 | out_size = 256 / 8 * s->sample_blocks * channels * |
| 1820 | − (av_get_bits_per_sample_fmt(avctx->sample_fmt) / 8); | |
| 1820 | + av_get_bytes_per_sample(avctx->sample_fmt); | |
| 1821 | 1821 | if (*data_size < out_size) |
| 1822 | 1822 | return -1; |
| 1823 | 1823 | *data_size = out_size; |
| @@ -542,6 +542,9 @@ skip_mean_and_median: · 541 unmodified lines | ||
| 542 | 542 | ff_thread_await_progress((AVFrame *) s->last_picture_ptr, |
| 543 | 543 | mb_y, 0); |
| 544 | 544 | } |
| 545 | + if (!s->last_picture.motion_val[0] || | |
| 546 | + !s->last_picture.ref_index[0]) | |
| 547 | + goto skip_last_mv; | |
| 545 | 548 | prev_x = s->last_picture.motion_val[0][mot_index][0]; |
| 546 | 549 | prev_y = s->last_picture.motion_val[0][mot_index][1]; |
| 547 | 550 | prev_ref = s->last_picture.ref_index[0][4*mb_xy]; |
| @@ -556,6 +559,7 @@ skip_mean_and_median: · 8 unmodified lines | ||
| 556 | 559 | mv_predictor[pred_count][1]= prev_y; |
| 557 | 560 | ref [pred_count] = prev_ref; |
| 558 | 561 | pred_count++; |
| 562 | + skip_last_mv: | |
| 559 | 563 | |
| 560 | 564 | s->mv_dir = MV_DIR_FORWARD; |
| 561 | 565 | s->mb_intra=0; |
| @@ -3690,6 +3690,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ · 3689 unmodified lines | ||
| 3690 | 3690 | switch (hx->nal_unit_type) { |
| 3691 | 3691 | case NAL_SPS: |
| 3692 | 3692 | case NAL_PPS: |
| 3693 | + case NAL_IDR_SLICE: | |
| 3694 | + case NAL_SLICE: | |
| 3693 | 3695 | nals_needed = nal_index; |
| 3694 | 3696 | } |
| 3695 | 3697 | continue; |
| @@ -239,8 +239,8 @@ ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, · 238 unmodified lines | ||
| 239 | 239 | |
| 240 | 240 | s->sample_fmt[0] = sample_fmt_in; |
| 241 | 241 | s->sample_fmt[1] = sample_fmt_out; |
| 242 | − s->sample_size[0] = av_get_bits_per_sample_fmt(s->sample_fmt[0]) >> 3; | |
| 243 | − s->sample_size[1] = av_get_bits_per_sample_fmt(s->sample_fmt[1]) >> 3; | |
| 242 | + s->sample_size[0] = av_get_bytes_per_sample(s->sample_fmt[0]); | |
| 243 | + s->sample_size[1] = av_get_bytes_per_sample(s->sample_fmt[1]); | |
| 244 | 244 | |
| 245 | 245 | if (s->sample_fmt[0] != AV_SAMPLE_FMT_S16) { |
| 246 | 246 | if (!(s->convert_ctx[0] = av_audio_convert_alloc(AV_SAMPLE_FMT_S16, 1, |
| @@ -1210,7 +1210,7 @@ int av_get_bits_per_sample(enum CodecID codec_id){ · 1209 unmodified lines | ||
| 1210 | 1210 | |
| 1211 | 1211 | #if FF_API_OLD_SAMPLE_FMT |
| 1212 | 1212 | int av_get_bits_per_sample_format(enum AVSampleFormat sample_fmt) { |
| 1213 | − return av_get_bits_per_sample_fmt(sample_fmt); | |
| 1213 | + return av_get_bytes_per_sample(sample_fmt) << 3; | |
| 1214 | 1214 | } |
| 1215 | 1215 | #endif |
| 1216 | 1216 | |
| @@ -450,7 +450,7 @@ static av_cold int vmdaudio_decode_init(AVCodecContext *avctx) · 449 unmodified lines | ||
| 450 | 450 | avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 451 | 451 | else |
| 452 | 452 | avctx->sample_fmt = AV_SAMPLE_FMT_U8; |
| 453 | − s->out_bps = av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3; | |
| 453 | + s->out_bps = av_get_bytes_per_sample(avctx->sample_fmt); | |
| 454 | 454 | |
| 455 | 455 | av_log(avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, " |
| 456 | 456 | "block align = %d, sample rate = %d\n", |
| @@ -1646,7 +1646,7 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, · 1645 unmodified lines | ||
| 1646 | 1646 | vc->audio_channels); |
| 1647 | 1647 | |
| 1648 | 1648 | *data_size = len * vc->audio_channels * |
| 1649 | − (av_get_bits_per_sample_fmt(avccontext->sample_fmt) / 8); | |
| 1649 | + av_get_bytes_per_sample(avccontext->sample_fmt); | |
| 1650 | 1650 | |
| 1651 | 1651 | return buf_size ; |
| 1652 | 1652 | } |
| @@ -0,0 +1,148 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> | |
| 3 | + * | |
| 4 | + * This file is part of Libav. | |
| 5 | + * | |
| 6 | + * Libav is free software; you can redistribute it and/or | |
| 7 | + * modify it under the terms of the GNU Lesser General Public | |
| 8 | + * License as published by the Free Software Foundation; either | |
| 9 | + * version 2.1 of the License, or (at your option) any later version. | |
| 10 | + * | |
| 11 | + * Libav is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | + * Lesser General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public | |
| 17 | + * License along with Libav; if not, write to the Free Software | |
| 18 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 19 | + */ | |
| 20 | + | |
| 21 | +#ifndef AVCODEC_X86_CABAC_H | |
| 22 | +#define AVCODEC_X86_CABAC_H | |
| 23 | + | |
| 24 | +#include "libavcodec/cabac.h" | |
| 25 | +#include "libavutil/attributes.h" | |
| 26 | +#include "libavutil/x86_cpu.h" | |
| 27 | +#include "config.h" | |
| 28 | + | |
| 29 | +#if HAVE_FAST_CMOV | |
| 30 | +#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ | |
| 31 | + "mov "tmp" , %%ecx \n\t"\ | |
| 32 | + "shl $17 , "tmp" \n\t"\ | |
| 33 | + "cmp "low" , "tmp" \n\t"\ | |
| 34 | + "cmova %%ecx , "range" \n\t"\ | |
| 35 | + "sbb %%ecx , %%ecx \n\t"\ | |
| 36 | + "and %%ecx , "tmp" \n\t"\ | |
| 37 | + "sub "tmp" , "low" \n\t"\ | |
| 38 | + "xor %%ecx , "ret" \n\t" | |
| 39 | +#else /* HAVE_FAST_CMOV */ | |
| 40 | +#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ | |
| 41 | + "mov "tmp" , %%ecx \n\t"\ | |
| 42 | + "shl $17 , "tmp" \n\t"\ | |
| 43 | + "sub "low" , "tmp" \n\t"\ | |
| 44 | + "sar $31 , "tmp" \n\t" /*lps_mask*/\ | |
| 45 | + "sub %%ecx , "range" \n\t" /*RangeLPS - range*/\ | |
| 46 | + "and "tmp" , "range" \n\t" /*(RangeLPS - range)&lps_mask*/\ | |
| 47 | + "add %%ecx , "range" \n\t" /*new range*/\ | |
| 48 | + "shl $17 , %%ecx \n\t"\ | |
| 49 | + "and "tmp" , %%ecx \n\t"\ | |
| 50 | + "sub %%ecx , "low" \n\t"\ | |
| 51 | + "xor "tmp" , "ret" \n\t" | |
| 52 | +#endif /* HAVE_FAST_CMOV */ | |
| 53 | + | |
| 54 | +#define BRANCHLESS_GET_CABAC(ret, cabac, statep, low, lowword, range, tmp, tmpbyte, byte) \ | |
| 55 | + "movzbl "statep" , "ret" \n\t"\ | |
| 56 | + "mov "range" , "tmp" \n\t"\ | |
| 57 | + "and $0xC0 , "range" \n\t"\ | |
| 58 | + "movzbl "MANGLE(ff_h264_lps_range)"("ret", "range", 2), "range" \n\t"\ | |
| 59 | + "sub "range" , "tmp" \n\t"\ | |
| 60 | + BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, \ | |
| 61 | + range, tmp) \ | |
| 62 | + "movzbl " MANGLE(ff_h264_norm_shift) "("range"), %%ecx \n\t"\ | |
| 63 | + "shl %%cl , "range" \n\t"\ | |
| 64 | + "movzbl "MANGLE(ff_h264_mlps_state)"+128("ret"), "tmp" \n\t"\ | |
| 65 | + "mov "tmpbyte" , "statep" \n\t"\ | |
| 66 | + "shl %%cl , "low" \n\t"\ | |
| 67 | + "test "lowword" , "lowword" \n\t"\ | |
| 68 | + " jnz 1f \n\t"\ | |
| 69 | + "mov "byte"("cabac"), %%"REG_c" \n\t"\ | |
| 70 | + "movzwl (%%"REG_c") , "tmp" \n\t"\ | |
| 71 | + "bswap "tmp" \n\t"\ | |
| 72 | + "shr $15 , "tmp" \n\t"\ | |
| 73 | + "sub $0xFFFF , "tmp" \n\t"\ | |
| 74 | + "add $2 , %%"REG_c" \n\t"\ | |
| 75 | + "mov %%"REG_c" , "byte "("cabac") \n\t"\ | |
| 76 | + "lea -1("low") , %%ecx \n\t"\ | |
| 77 | + "xor "low" , %%ecx \n\t"\ | |
| 78 | + "shr $15 , %%ecx \n\t"\ | |
| 79 | + "movzbl " MANGLE(ff_h264_norm_shift) "(%%ecx), %%ecx \n\t"\ | |
| 80 | + "neg %%ecx \n\t"\ | |
| 81 | + "add $7 , %%ecx \n\t"\ | |
| 82 | + "shl %%cl , "tmp" \n\t"\ | |
| 83 | + "add "tmp" , "low" \n\t"\ | |
| 84 | + "1: \n\t" | |
| 85 | + | |
| 86 | +#if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) | |
| 87 | +#define get_cabac_inline get_cabac_inline_x86 | |
| 88 | +static av_always_inline int get_cabac_inline_x86(CABACContext *c, | |
| 89 | + uint8_t *const state) | |
| 90 | +{ | |
| 91 | + int bit, low, range, tmp; | |
| 92 | + | |
| 93 | + __asm__ volatile( | |
| 94 | + "movl %a6(%5), %2 \n\t" | |
| 95 | + "movl %a7(%5), %1 \n\t" | |
| 96 | + BRANCHLESS_GET_CABAC("%0", "%5", "(%4)", "%1", "%w1", "%2", | |
| 97 | + "%3", "%b3", "%a8") | |
| 98 | + "movl %2, %a6(%5) \n\t" | |
| 99 | + "movl %1, %a7(%5) \n\t" | |
| 100 | + | |
| 101 | + :"=&r"(bit), "=&r"(low), "=&r"(range), "=&q"(tmp) | |
| 102 | + :"r"(state), "r"(c), | |
| 103 | + "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), | |
| 104 | + "i"(offsetof(CABACContext, bytestream)) | |
| 105 | + : "%"REG_c, "memory" | |
| 106 | + ); | |
| 107 | + return bit & 1; | |
| 108 | +} | |
| 109 | +#endif /* ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ | |
| 110 | + | |
| 111 | +#define get_cabac_bypass_sign get_cabac_bypass_sign_x86 | |
| 112 | +static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val) | |
| 113 | +{ | |
| 114 | + x86_reg tmp; | |
| 115 | + __asm__ volatile( | |
| 116 | + "movl %a3(%2), %k1 \n\t" | |
| 117 | + "movl %a4(%2), %%eax \n\t" | |
| 118 | + "shl $17, %k1 \n\t" | |
| 119 | + "add %%eax, %%eax \n\t" | |
| 120 | + "sub %k1, %%eax \n\t" | |
| 121 | + "cltd \n\t" | |
| 122 | + "and %%edx, %k1 \n\t" | |
| 123 | + "add %k1, %%eax \n\t" | |
| 124 | + "xor %%edx, %%ecx \n\t" | |
| 125 | + "sub %%edx, %%ecx \n\t" | |
| 126 | + "test %%ax, %%ax \n\t" | |
| 127 | + " jnz 1f \n\t" | |
| 128 | + "mov %a5(%2), %1 \n\t" | |
| 129 | + "subl $0xFFFF, %%eax \n\t" | |
| 130 | + "movzwl (%1), %%edx \n\t" | |
| 131 | + "bswap %%edx \n\t" | |
| 132 | + "shrl $15, %%edx \n\t" | |
| 133 | + "add $2, %1 \n\t" | |
| 134 | + "addl %%edx, %%eax \n\t" | |
| 135 | + "mov %1, %a5(%2) \n\t" | |
| 136 | + "1: \n\t" | |
| 137 | + "movl %%eax, %a4(%2) \n\t" | |
| 138 | + | |
| 139 | + :"+c"(val), "=&r"(tmp) | |
| 140 | + :"r"(c), | |
| 141 | + "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), | |
| 142 | + "i"(offsetof(CABACContext, bytestream)) | |
| 143 | + : "%eax", "%edx", "memory" | |
| 144 | + ); | |
| 145 | + return val; | |
| 146 | +} | |
| 147 | + | |
| 148 | +#endif /* AVCODEC_X86_CABAC_H */ | |
| @@ -29,63 +29,72 @@ · 28 unmodified lines | ||
| 29 | 29 | #ifndef AVCODEC_X86_H264_I386_H |
| 30 | 30 | #define AVCODEC_X86_H264_I386_H |
| 31 | 31 | |
| 32 | +#include <stddef.h> | |
| 33 | + | |
| 32 | 34 | #include "libavcodec/cabac.h" |
| 35 | +#include "cabac.h" | |
| 33 | 36 | |
| 34 | 37 | //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet |
| 35 | 38 | //as that would make optimization work hard) |
| 36 | −#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) | |
| 39 | +#if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) | |
| 37 | 40 | static int decode_significance_x86(CABACContext *c, int max_coeff, |
| 38 | 41 | uint8_t *significant_coeff_ctx_base, |
| 39 | 42 | int *index, x86_reg last_off){ |
| 40 | 43 | void *end= significant_coeff_ctx_base + max_coeff - 1; |
| 41 | − int minusstart= -(int)significant_coeff_ctx_base; | |
| 42 | − int minusindex= 4-(int)index; | |
| 43 | − int coeff_count; | |
| 44 | + int minusstart= -(intptr_t)significant_coeff_ctx_base; | |
| 45 | + int minusindex= 4-(intptr_t)index; | |
| 46 | + int bit; | |
| 47 | + x86_reg coeff_count; | |
| 48 | + int low; | |
| 49 | + int range; | |
| 44 | 50 | __asm__ volatile( |
| 45 | − "movl "RANGE "(%3), %%esi \n\t" | |
| 46 | − "movl "LOW "(%3), %%ebx \n\t" | |
| 51 | + "movl %a11(%6), %5 \n\t" | |
| 52 | + "movl %a12(%6), %3 \n\t" | |
| 47 | 53 | |
| 48 | 54 | "2: \n\t" |
| 49 | 55 | |
| 50 | − BRANCHLESS_GET_CABAC("%%edx", "%3", "(%1)", "%%ebx", | |
| 51 | − "%%bx", "%%esi", "%%eax", "%%al") | |
| 56 | + BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3", | |
| 57 | + "%w3", "%5", "%k0", "%b0", "%a13") | |
| 52 | 58 | |
| 53 | − "test $1, %%edx \n\t" | |
| 59 | + "test $1, %4 \n\t" | |
| 54 | 60 | " jz 3f \n\t" |
| 55 | − "add %7, %1 \n\t" | |
| 61 | + "add %10, %1 \n\t" | |
| 56 | 62 | |
| 57 | − BRANCHLESS_GET_CABAC("%%edx", "%3", "(%1)", "%%ebx", | |
| 58 | − "%%bx", "%%esi", "%%eax", "%%al") | |
| 63 | + BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3", | |
| 64 | + "%w3", "%5", "%k0", "%b0", "%a13") | |
| 59 | 65 | |
| 60 | − "sub %7, %1 \n\t" | |
| 61 | − "mov %2, %%"REG_a" \n\t" | |
| 62 | − "movl %4, %%ecx \n\t" | |
| 66 | + "sub %10, %1 \n\t" | |
| 67 | + "mov %2, %0 \n\t" | |
| 68 | + "movl %7, %%ecx \n\t" | |
| 63 | 69 | "add %1, %%"REG_c" \n\t" |
| 64 | − "movl %%ecx, (%%"REG_a") \n\t" | |
| 70 | + "movl %%ecx, (%0) \n\t" | |
| 65 | 71 | |
| 66 | − "test $1, %%edx \n\t" | |
| 72 | + "test $1, %4 \n\t" | |
| 67 | 73 | " jnz 4f \n\t" |
| 68 | 74 | |
| 69 | − "add $4, %%"REG_a" \n\t" | |
| 70 | − "mov %%"REG_a", %2 \n\t" | |
| 75 | + "add $4, %0 \n\t" | |
| 76 | + "mov %0, %2 \n\t" | |
| 71 | 77 | |
| 72 | 78 | "3: \n\t" |
| 73 | 79 | "add $1, %1 \n\t" |
| 74 | − "cmp %5, %1 \n\t" | |
| 80 | + "cmp %8, %1 \n\t" | |
| 75 | 81 | " jb 2b \n\t" |
| 76 | − "mov %2, %%"REG_a" \n\t" | |
| 77 | − "movl %4, %%ecx \n\t" | |
| 82 | + "mov %2, %0 \n\t" | |
| 83 | + "movl %7, %%ecx \n\t" | |
| 78 | 84 | "add %1, %%"REG_c" \n\t" |
| 79 | − "movl %%ecx, (%%"REG_a") \n\t" | |
| 85 | + "movl %%ecx, (%0) \n\t" | |
| 80 | 86 | "4: \n\t" |
| 81 | − "add %6, %%eax \n\t" | |
| 82 | − "shr $2, %%eax \n\t" | |
| 83 | − | |
| 84 | − "movl %%esi, "RANGE "(%3) \n\t" | |
| 85 | − "movl %%ebx, "LOW "(%3) \n\t" | |
| 86 | − :"=&a"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index) | |
| 87 | − :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off) | |
| 88 | − : "%"REG_c, "%ebx", "%edx", "%esi", "memory" | |
| 87 | + "add %9, %k0 \n\t" | |
| 88 | + "shr $2, %k0 \n\t" | |
| 89 | + | |
| 90 | + "movl %5, %a11(%6) \n\t" | |
| 91 | + "movl %3, %a12(%6) \n\t" | |
| 92 | + :"=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), | |
| 93 | + "=&r"(low), "=&r"(bit), "=&r"(range) | |
| 94 | + :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), | |
| 95 | + "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), | |
| 96 | + "i"(offsetof(CABACContext, bytestream)) | |
| 97 | + : "%"REG_c, "memory" | |
| 89 | 98 | ); |
| 90 | 99 | return coeff_count; |
| 91 | 100 | } |
| @@ -93,64 +102,70 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, · 1 unmodified line | ||
| 93 | 102 | static int decode_significance_8x8_x86(CABACContext *c, |
| 94 | 103 | uint8_t *significant_coeff_ctx_base, |
| 95 | 104 | int *index, x86_reg last_off, const uint8_t *sig_off){ |
| 96 | − int minusindex= 4-(int)index; | |
| 97 | − int coeff_count; | |
| 105 | + int minusindex= 4-(intptr_t)index; | |
| 106 | + int bit; | |
| 107 | + x86_reg coeff_count; | |
| 108 | + int low; | |
| 109 | + int range; | |
| 98 | 110 | x86_reg last=0; |
| 111 | + x86_reg state; | |
| 99 | 112 | __asm__ volatile( |
| 100 | − "movl "RANGE "(%3), %%esi \n\t" | |
| 101 | − "movl "LOW "(%3), %%ebx \n\t" | |
| 113 | + "movl %a12(%7), %5 \n\t" | |
| 114 | + "movl %a13(%7), %3 \n\t" | |
| 102 | 115 | |
| 103 | − "mov %1, %%"REG_D" \n\t" | |
| 116 | + "mov %1, %6 \n\t" | |
| 104 | 117 | "2: \n\t" |
| 105 | 118 | |
| 106 | − "mov %6, %%"REG_a" \n\t" | |
| 107 | − "movzbl (%%"REG_a", %%"REG_D"), %%edi \n\t" | |
| 108 | − "add %5, %%"REG_D" \n\t" | |
| 119 | + "mov %10, %0 \n\t" | |
| 120 | + "movzbl (%0, %6), %k6 \n\t" | |
| 121 | + "add %9, %6 \n\t" | |
| 109 | 122 | |
| 110 | − BRANCHLESS_GET_CABAC("%%edx", "%3", "(%%"REG_D")", "%%ebx", | |
| 111 | − "%%bx", "%%esi", "%%eax", "%%al") | |
| 123 | + BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3", | |
| 124 | + "%w3", "%5", "%k0", "%b0", "%a14") | |
| 112 | 125 | |
| 113 | − "mov %1, %%edi \n\t" | |
| 114 | − "test $1, %%edx \n\t" | |
| 126 | + "mov %1, %k6 \n\t" | |
| 127 | + "test $1, %4 \n\t" | |
| 115 | 128 | " jz 3f \n\t" |
| 116 | 129 | |
| 117 | − "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%%edi), %%edi\n\t" | |
| 118 | − "add %5, %%"REG_D" \n\t" | |
| 119 | − "add %7, %%"REG_D" \n\t" | |
| 130 | + "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t" | |
| 131 | + "add %9, %6 \n\t" | |
| 132 | + "add %11, %6 \n\t" | |
| 120 | 133 | |
| 121 | − BRANCHLESS_GET_CABAC("%%edx", "%3", "(%%"REG_D")", "%%ebx", | |
| 122 | − "%%bx", "%%esi", "%%eax", "%%al") | |
| 134 | + BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3", | |
| 135 | + "%w3", "%5", "%k0", "%b0", "%a14") | |
| 123 | 136 | |
| 124 | − "mov %2, %%"REG_a" \n\t" | |
| 125 | − "mov %1, %%edi \n\t" | |
| 126 | − "movl %%edi, (%%"REG_a") \n\t" | |
| 137 | + "mov %2, %0 \n\t" | |
| 138 | + "mov %1, %k6 \n\t" | |
| 139 | + "movl %k6, (%0) \n\t" | |
| 127 | 140 | |
| 128 | − "test $1, %%edx \n\t" | |
| 141 | + "test $1, %4 \n\t" | |
| 129 | 142 | " jnz 4f \n\t" |
| 130 | 143 | |
| 131 | − "add $4, %%"REG_a" \n\t" | |
| 132 | − "mov %%"REG_a", %2 \n\t" | |
| 144 | + "add $4, %0 \n\t" | |
| 145 | + "mov %0, %2 \n\t" | |
| 133 | 146 | |
| 134 | 147 | "3: \n\t" |
| 135 | − "addl $1, %%edi \n\t" | |
| 136 | − "mov %%edi, %1 \n\t" | |
| 137 | − "cmpl $63, %%edi \n\t" | |
| 148 | + "addl $1, %k6 \n\t" | |
| 149 | + "mov %k6, %1 \n\t" | |
| 150 | + "cmpl $63, %k6 \n\t" | |
| 138 | 151 | " jb 2b \n\t" |
| 139 | − "mov %2, %%"REG_a" \n\t" | |
| 140 | − "movl %%edi, (%%"REG_a") \n\t" | |
| 152 | + "mov %2, %0 \n\t" | |
| 153 | + "movl %k6, (%0) \n\t" | |
| 141 | 154 | "4: \n\t" |
| 142 | − "addl %4, %%eax \n\t" | |
| 143 | − "shr $2, %%eax \n\t" | |
| 144 | − | |
| 145 | − "movl %%esi, "RANGE "(%3) \n\t" | |
| 146 | − "movl %%ebx, "LOW "(%3) \n\t" | |
| 147 | − :"=&a"(coeff_count),"+m"(last), "+m"(index) | |
| 148 | − :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off) | |
| 149 | − : "%"REG_c, "%ebx", "%edx", "%esi", "%"REG_D, "memory" | |
| 155 | + "addl %8, %k0 \n\t" | |
| 156 | + "shr $2, %k0 \n\t" | |
| 157 | + | |
| 158 | + "movl %5, %a12(%7) \n\t" | |
| 159 | + "movl %3, %a13(%7) \n\t" | |
| 160 | + :"=&q"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit), | |
| 161 | + "=&r"(range), "=&r"(state) | |
| 162 | + :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off), | |
| 163 | + "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), | |
| 164 | + "i"(offsetof(CABACContext, bytestream)) | |
| 165 | + : "%"REG_c, "memory" | |
| 150 | 166 | ); |
| 151 | 167 | return coeff_count; |
| 152 | 168 | } |
| 153 | −#endif /* ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE */ | |
| 154 | − /* !defined(BROKEN_RELOCATIONS) */ | |
| 169 | +#endif /* ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ | |
| 155 | 170 | |
| 156 | 171 | #endif /* AVCODEC_X86_H264_I386_H */ |
| @@ -527,7 +527,7 @@ static int mkv_write_tracks(AVFormatContext *s) · 526 unmodified lines | ||
| 527 | 527 | AVDictionaryEntry *tag; |
| 528 | 528 | |
| 529 | 529 | if (!bit_depth) |
| 530 | − bit_depth = av_get_bits_per_sample_fmt(codec->sample_fmt); | |
| 530 | + bit_depth = av_get_bytes_per_sample(codec->sample_fmt) << 3; | |
| 531 | 531 | |
| 532 | 532 | if (codec->codec_id == CODEC_ID_AAC) |
| 533 | 533 | get_aac_sample_rates(s, codec, &sample_rate, &output_sample_rate); |
| @@ -2202,7 +2202,7 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 2201 unmodified lines | ||
| 2202 | 2202 | time = avio_rb64(pb); |
| 2203 | 2203 | } else { |
| 2204 | 2204 | duration = avio_rb32(pb); /* segment duration */ |
| 2205 | − time = avio_rb32(pb); /* media time */ | |
| 2205 | + time = (int32_t)avio_rb32(pb); /* media time */ | |
| 2206 | 2206 | } |
| 2207 | 2207 | avio_rb32(pb); /* Media rate */ |
| 2208 | 2208 | if (i == 0 && time >= -1) { |
| @@ -29,9 +29,9 @@ · 28 unmodified lines | ||
| 29 | 29 | |
| 30 | 30 | #include "libavutil/avutil.h" |
| 31 | 31 | |
| 32 | −#define LIBSWSCALE_VERSION_MAJOR 0 | |
| 33 | −#define LIBSWSCALE_VERSION_MINOR 14 | |
| 34 | −#define LIBSWSCALE_VERSION_MICRO 1 | |
| 32 | +#define LIBSWSCALE_VERSION_MAJOR 2 | |
| 33 | +#define LIBSWSCALE_VERSION_MINOR 0 | |
| 34 | +#define LIBSWSCALE_VERSION_MICRO 0 | |
| 35 | 35 | |
| 36 | 36 | #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ |
| 37 | 37 | LIBSWSCALE_VERSION_MINOR, \ |
| @@ -48,13 +48,13 @@ · 10 unmodified lines | ||
| 48 | 48 | * They may change, break or disappear at any time. |
| 49 | 49 | */ |
| 50 | 50 | #ifndef FF_API_SWS_GETCONTEXT |
| 51 | −#define FF_API_SWS_GETCONTEXT (LIBSWSCALE_VERSION_MAJOR < 2) | |
| 51 | +#define FF_API_SWS_GETCONTEXT (LIBSWSCALE_VERSION_MAJOR < 3) | |
| 52 | 52 | #endif |
| 53 | 53 | #ifndef FF_API_SWS_CPU_CAPS |
| 54 | −#define FF_API_SWS_CPU_CAPS (LIBSWSCALE_VERSION_MAJOR < 2) | |
| 54 | +#define FF_API_SWS_CPU_CAPS (LIBSWSCALE_VERSION_MAJOR < 3) | |
| 55 | 55 | #endif |
| 56 | 56 | #ifndef FF_API_SWS_FORMAT_NAME |
| 57 | −#define FF_API_SWS_FORMAT_NAME (LIBSWSCALE_VERSION_MAJOR < 2) | |
| 57 | +#define FF_API_SWS_FORMAT_NAME (LIBSWSCALE_VERSION_MAJOR < 3) | |
| 58 | 58 | #endif |
| 59 | 59 | |
| 60 | 60 | /** |