| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder | 
					
						
							|  |  |  |  * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is part of FFmpeg. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * FFmpeg is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License as published by the Free Software Foundation; either | 
					
						
							|  |  |  |  * version 2.1 of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * FFmpeg is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  |  * Lesser General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License along with FFmpeg; if not, write to the Free Software | 
					
						
							|  |  |  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2010-04-20 14:45:34 +00:00
										 |  |  |  * @file | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  |  * H.264 / AVC / MPEG4 part10 codec. | 
					
						
							|  |  |  |  * non-MMX i386-specific optimizations for H.264 | 
					
						
							|  |  |  |  * @author Michael Niedermayer <michaelni@gmx.at> | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-22 09:12:42 +00:00
										 |  |  | #ifndef AVCODEC_X86_H264_I386_H
 | 
					
						
							|  |  |  | #define AVCODEC_X86_H264_I386_H
 | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-20 01:54:32 +01:00
										 |  |  | #include <stddef.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-09 11:56:36 +00:00
										 |  |  | #include "libavcodec/cabac.h"
 | 
					
						
							| 
									
										
										
										
											2011-06-20 10:53:41 +01:00
										 |  |  | #include "cabac.h"
 | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-16 20:43:37 +00:00
										 |  |  | //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet
 | 
					
						
							|  |  |  | //as that would make optimization work hard)
 | 
					
						
							| 
									
										
										
										
											2012-04-21 02:09:27 +02:00
										 |  |  | #if HAVE_7REGS && !defined(BROKEN_RELOCATIONS)
 | 
					
						
							| 
									
										
										
										
											2008-04-16 20:43:37 +00:00
										 |  |  | static int decode_significance_x86(CABACContext *c, int max_coeff, | 
					
						
							|  |  |  |                                    uint8_t *significant_coeff_ctx_base, | 
					
						
							| 
									
										
										
										
											2011-06-03 01:12:28 -07:00
										 |  |  |                                    int *index, x86_reg last_off){ | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  |     void *end= significant_coeff_ctx_base + max_coeff - 1; | 
					
						
							| 
									
										
										
										
											2011-06-20 10:24:26 +01:00
										 |  |  |     int minusstart= -(intptr_t)significant_coeff_ctx_base; | 
					
						
							|  |  |  |     int minusindex= 4-(intptr_t)index; | 
					
						
							| 
									
										
										
										
											2011-06-20 10:06:07 +01:00
										 |  |  |     int bit; | 
					
						
							| 
									
										
										
										
											2011-06-20 09:23:26 +01:00
										 |  |  |     x86_reg coeff_count; | 
					
						
							| 
									
										
										
										
											2008-10-16 13:34:09 +00:00
										 |  |  |     __asm__ volatile( | 
					
						
							| 
									
										
										
										
											2012-03-17 09:04:32 -07:00
										 |  |  |         "3:                                     \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-21 02:09:27 +02:00
										 |  |  |         BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", "%w3", | 
					
						
							|  |  |  |                              "%5", "%k0", "%b0", | 
					
						
							|  |  |  |                              "%a11(%6)", "%a12(%6)") | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-20 10:06:07 +01:00
										 |  |  |         "test $1, %4                            \n\t" | 
					
						
							| 
									
										
										
										
											2012-03-17 09:04:32 -07:00
										 |  |  |         " jz 4f                                 \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 10:12:29 +01:00
										 |  |  |         "add  %10, %1                           \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-21 02:09:27 +02:00
										 |  |  |         BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", "%w3", | 
					
						
							|  |  |  |                              "%5", "%k0", "%b0", | 
					
						
							|  |  |  |                              "%a11(%6)", "%a12(%6)") | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-20 10:12:29 +01:00
										 |  |  |         "sub  %10, %1                           \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 09:23:26 +01:00
										 |  |  |         "mov  %2, %0                            \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 10:12:29 +01:00
										 |  |  |         "movl %7, %%ecx                         \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  |         "add  %1, %%"REG_c"                     \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 09:23:26 +01:00
										 |  |  |         "movl %%ecx, (%0)                       \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-20 10:06:07 +01:00
										 |  |  |         "test $1, %4                            \n\t" | 
					
						
							| 
									
										
										
										
											2012-03-17 09:04:32 -07:00
										 |  |  |         " jnz 5f                                \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-29 01:55:58 +01:00
										 |  |  |         "add"OPSIZE"  $4, %2                    \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-17 09:04:32 -07:00
										 |  |  |         "4:                                     \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  |         "add  $1, %1                            \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 10:12:29 +01:00
										 |  |  |         "cmp  %8, %1                            \n\t" | 
					
						
							| 
									
										
										
										
											2012-03-17 09:04:32 -07:00
										 |  |  |         " jb 3b                                 \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 09:23:26 +01:00
										 |  |  |         "mov  %2, %0                            \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 10:12:29 +01:00
										 |  |  |         "movl %7, %%ecx                         \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  |         "add  %1, %%"REG_c"                     \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 09:23:26 +01:00
										 |  |  |         "movl %%ecx, (%0)                       \n\t" | 
					
						
							| 
									
										
										
										
											2012-03-17 09:04:32 -07:00
										 |  |  |         "5:                                     \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 10:12:29 +01:00
										 |  |  |         "add  %9, %k0                           \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 09:23:26 +01:00
										 |  |  |         "shr $2, %k0                            \n\t" | 
					
						
							| 
									
										
										
										
											2012-03-17 09:02:44 -07:00
										 |  |  |         : "=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), | 
					
						
							|  |  |  |           "+&r"(c->low), "=&r"(bit), "+&r"(c->range) | 
					
						
							|  |  |  |         : "r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), | 
					
						
							| 
									
										
										
										
											2012-03-17 09:09:41 -07:00
										 |  |  |           "i"(offsetof(CABACContext, bytestream)), | 
					
						
							| 
									
										
										
										
											2012-04-21 02:09:27 +02:00
										 |  |  |           "i"(offsetof(CABACContext, bytestream_end)) | 
					
						
							| 
									
										
										
										
											2011-06-20 10:12:29 +01:00
										 |  |  |         : "%"REG_c, "memory" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  |     ); | 
					
						
							|  |  |  |     return coeff_count; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-16 20:43:37 +00:00
										 |  |  | static int decode_significance_8x8_x86(CABACContext *c, | 
					
						
							|  |  |  |                                        uint8_t *significant_coeff_ctx_base, | 
					
						
							| 
									
										
										
										
											2011-07-26 19:08:05 -07:00
										 |  |  |                                        int *index, uint8_t *last_coeff_ctx_base, const uint8_t *sig_off){ | 
					
						
							| 
									
										
										
										
											2011-06-20 10:24:26 +01:00
										 |  |  |     int minusindex= 4-(intptr_t)index; | 
					
						
							| 
									
										
										
										
											2011-06-20 10:06:07 +01:00
										 |  |  |     int bit; | 
					
						
							| 
									
										
										
										
											2011-06-20 09:23:26 +01:00
										 |  |  |     x86_reg coeff_count; | 
					
						
							| 
									
										
										
										
											2008-05-08 21:11:24 +00:00
										 |  |  |     x86_reg last=0; | 
					
						
							| 
									
										
										
										
											2011-06-20 10:20:15 +01:00
										 |  |  |     x86_reg state; | 
					
						
							| 
									
										
										
										
											2008-10-16 13:34:09 +00:00
										 |  |  |     __asm__ volatile( | 
					
						
							| 
									
										
										
										
											2011-06-20 10:20:15 +01:00
										 |  |  |         "mov %1, %6                             \n\t" | 
					
						
							| 
									
										
										
										
											2012-03-17 09:04:32 -07:00
										 |  |  |         "3:                                     \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-20 10:20:15 +01:00
										 |  |  |         "mov %10, %0                            \n\t" | 
					
						
							|  |  |  |         "movzbl (%0, %6), %k6                   \n\t" | 
					
						
							|  |  |  |         "add %9, %6                             \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-21 02:09:27 +02:00
										 |  |  |         BRANCHLESS_GET_CABAC("%4", "(%6)", "%3", "%w3", | 
					
						
							|  |  |  |                              "%5", "%k0", "%b0", | 
					
						
							|  |  |  |                              "%a12(%7)", "%a13(%7)") | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-20 10:20:15 +01:00
										 |  |  |         "mov %1, %k6                            \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 10:06:07 +01:00
										 |  |  |         "test $1, %4                            \n\t" | 
					
						
							| 
									
										
										
										
											2012-03-17 09:04:32 -07:00
										 |  |  |         " jz 4f                                 \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-21 02:09:27 +02:00
										 |  |  |         "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 10:20:15 +01:00
										 |  |  |         "add %11, %6                            \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-21 02:09:27 +02:00
										 |  |  |         BRANCHLESS_GET_CABAC("%4", "(%6)", "%3", "%w3", | 
					
						
							|  |  |  |                              "%5", "%k0", "%b0", | 
					
						
							|  |  |  |                              "%a12(%7)", "%a13(%7)") | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-20 09:23:26 +01:00
										 |  |  |         "mov %2, %0                             \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 10:20:15 +01:00
										 |  |  |         "mov %1, %k6                            \n\t" | 
					
						
							|  |  |  |         "movl %k6, (%0)                         \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-20 10:06:07 +01:00
										 |  |  |         "test $1, %4                            \n\t" | 
					
						
							| 
									
										
										
										
											2012-03-17 09:04:32 -07:00
										 |  |  |         " jnz 5f                                \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-29 01:55:58 +01:00
										 |  |  |         "add"OPSIZE"  $4, %2                    \n\t" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-17 09:04:32 -07:00
										 |  |  |         "4:                                     \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 10:20:15 +01:00
										 |  |  |         "addl $1, %k6                           \n\t" | 
					
						
							|  |  |  |         "mov %k6, %1                            \n\t" | 
					
						
							|  |  |  |         "cmpl $63, %k6                          \n\t" | 
					
						
							| 
									
										
										
										
											2012-03-17 09:04:32 -07:00
										 |  |  |         " jb 3b                                 \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 09:23:26 +01:00
										 |  |  |         "mov %2, %0                             \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 10:20:15 +01:00
										 |  |  |         "movl %k6, (%0)                         \n\t" | 
					
						
							| 
									
										
										
										
											2012-03-17 09:04:32 -07:00
										 |  |  |         "5:                                     \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 10:20:15 +01:00
										 |  |  |         "addl %8, %k0                           \n\t" | 
					
						
							| 
									
										
										
										
											2011-06-20 09:23:26 +01:00
										 |  |  |         "shr $2, %k0                            \n\t" | 
					
						
							| 
									
										
										
										
											2012-03-17 09:02:44 -07:00
										 |  |  |         : "=&q"(coeff_count), "+m"(last), "+m"(index), "+&r"(c->low), | 
					
						
							|  |  |  |           "=&r"(bit), "+&r"(c->range), "=&r"(state) | 
					
						
							|  |  |  |         : "r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), | 
					
						
							|  |  |  |           "m"(sig_off), "m"(last_coeff_ctx_base), | 
					
						
							| 
									
										
										
										
											2012-03-17 09:09:41 -07:00
										 |  |  |           "i"(offsetof(CABACContext, bytestream)), | 
					
						
							| 
									
										
										
										
											2012-04-21 02:09:27 +02:00
										 |  |  |           "i"(offsetof(CABACContext, bytestream_end)) | 
					
						
							| 
									
										
										
										
											2011-06-20 10:20:15 +01:00
										 |  |  |         : "%"REG_c, "memory" | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  |     ); | 
					
						
							|  |  |  |     return coeff_count; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2011-12-26 21:47:20 +02:00
										 |  |  | #endif /* HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */
 | 
					
						
							| 
									
										
										
										
											2008-04-16 04:40:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-22 09:12:42 +00:00
										 |  |  | #endif /* AVCODEC_X86_H264_I386_H */
 |