summaryrefslogtreecommitdiff
path: root/libavcodec/h264.c
diff options
context:
space:
mode:
authorOskar Arvidsson <oskar@irock.se>2011-03-29 17:48:58 +0200
committerRonald S. Bultje <rsbultje@gmail.com>2011-05-10 07:24:35 -0400
commitfcc0224e4fbd44ae268903185b0cf83560b13555 (patch)
treed41ef6b55e9cf1575c4077c7f44cf25b93a99fb9 /libavcodec/h264.c
parent6e3ef511d787ff632547059f8730396ff4498e70 (diff)
Add support for higher QP values in h264.
In high bit depth, the QP values may now be up to (51 + 6*(bit_depth-8)). Preparatory patch for high bit depth h264 decoding support. Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r--libavcodec/h264.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index e02b277769..0fcb7dbbdb 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -44,12 +44,12 @@
//#undef NDEBUG
#include <assert.h>
-static const uint8_t rem6[52]={
-0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3,
+static const uint8_t rem6[QP_MAX_NUM+1]={
+0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3,
};
-static const uint8_t div6[52]={
-0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
+static const uint8_t div6[QP_MAX_NUM+1]={
+0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9,10,10,10,10,
};
static const enum PixelFormat hwaccel_pixfmt_list_h264_jpeg_420[] = {
@@ -658,6 +658,7 @@ static void free_tables(H264Context *h, int free_rbsp){
static void init_dequant8_coeff_table(H264Context *h){
int i,q,x;
+ const int max_qp = 51 + 6*(h->sps.bit_depth_luma-8);
h->dequant8_coeff[0] = h->dequant8_buffer[0];
h->dequant8_coeff[1] = h->dequant8_buffer[1];
@@ -667,7 +668,7 @@ static void init_dequant8_coeff_table(H264Context *h){
break;
}
- for(q=0; q<52; q++){
+ for(q=0; q<max_qp+1; q++){
int shift = div6[q];
int idx = rem6[q];
for(x=0; x<64; x++)
@@ -680,6 +681,7 @@ static void init_dequant8_coeff_table(H264Context *h){
static void init_dequant4_coeff_table(H264Context *h){
int i,j,q,x;
+ const int max_qp = 51 + 6*(h->sps.bit_depth_luma-8);
for(i=0; i<6; i++ ){
h->dequant4_coeff[i] = h->dequant4_buffer[i];
for(j=0; j<i; j++){
@@ -691,7 +693,7 @@ static void init_dequant4_coeff_table(H264Context *h){
if(j<i)
continue;
- for(q=0; q<52; q++){
+ for(q=0; q<max_qp+1; q++){
int shift = div6[q] + 2;
int idx = rem6[q];
for(x=0; x<16; x++)
@@ -893,6 +895,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx){
ff_h264_decode_init_vlc();
h->pixel_shift = 0;
+ h->sps.bit_depth_luma = 8;
h->thread_context[0] = h;
h->outputed_poc = INT_MIN;
@@ -1387,7 +1390,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i
for(i=16; i<16+8; i++){
if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
uint8_t * const ptr= dest[(i&4)>>2] + block_offset[i];
- ff_svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, ff_h264_chroma_qp[s->qscale + 12] - 12, 2);
+ ff_svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, ff_h264_chroma_qp[0][s->qscale + 12] - 12, 2);
}
}
}
@@ -2185,7 +2188,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
h->last_qscale_diff = 0;
tmp = h->pps.init_qp + get_se_golomb(&s->gb);
- if(tmp>51){
+ if(tmp>51+6*(h->sps.bit_depth_luma-8)){
av_log(s->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
return -1;
}