diff options
-rw-r--r-- | src/libvdpau/h264_parser.c | 15 | ||||
-rw-r--r-- | src/libvdpau/nal.h | 26 | ||||
-rw-r--r-- | src/libvdpau/vdpau_h264.c | 21 |
3 files changed, 45 insertions, 17 deletions
diff --git a/src/libvdpau/h264_parser.c b/src/libvdpau/h264_parser.c index abd4c329d..da375fa78 100644 --- a/src/libvdpau/h264_parser.c +++ b/src/libvdpau/h264_parser.c @@ -344,6 +344,8 @@ void parse_scaling_list(struct buf_reader *buf, uint8_t *scaling_list, uint8_t use_default_scaling_matrix_flag = 0; int i; + uint8_t *zigzag = (length==64) ? zigzag_8x8 : zigzag_4x4; + for (i = 0; i < length; i++) { if (next_scale != 0) { delta_scale = read_exp_golomb_s(buf); @@ -353,8 +355,7 @@ void parse_scaling_list(struct buf_reader *buf, uint8_t *scaling_list, break; } } - scaling_list[i] = (next_scale == 0) ? last_scale : next_scale; - last_scale = scaling_list[i]; + scaling_list[zigzag[i]] = last_scale = (next_scale == 0) ? last_scale : next_scale; } if (use_default_scaling_matrix_flag) { @@ -388,6 +389,9 @@ uint8_t parse_sps(struct buf_reader *buf, struct nal_parser *parser) buf->cur_pos = buf->buf + 3; sps->seq_parameter_set_id = read_exp_golomb(buf); + + memset(sps->scaling_lists_4x4, 16, sizeof(sps->scaling_lists_4x4)); + memset(sps->scaling_lists_8x8, 16, sizeof(sps->scaling_lists_4x4)); if (sps->profile_idc == 100 || sps->profile_idc == 110 || sps->profile_idc == 122 || sps->profile_idc == 144) { sps->chroma_format_idc = read_exp_golomb(buf); @@ -414,11 +418,6 @@ uint8_t parse_sps(struct buf_reader *buf, struct nal_parser *parser) } } - if (!sps->seq_scaling_matrix_present_flag) { - memset(sps->scaling_lists_4x4, 16, sizeof(sps->scaling_lists_4x4)); - memset(sps->scaling_lists_8x8, 16, sizeof(sps->scaling_lists_4x4)); - } - sps->log2_max_frame_num_minus4 = read_exp_golomb(buf); sps->pic_order_cnt_type = read_exp_golomb(buf); @@ -675,6 +674,8 @@ uint8_t parse_pps(struct buf_reader *buf, struct pic_parameter_set_rbsp *pps, int bit_length = (buf->len*8)-rbsp_trailing_bits(buf->buf, buf->len); int bit_read = bits_read(buf); + memset(pps->scaling_lists_4x4, 16, sizeof(pps->scaling_lists_4x4)); + memset(pps->scaling_lists_8x8, 16, sizeof(pps->scaling_lists_4x4)); if (bit_length-bit_read > 1) { printf("Read transform 8x8\n"); pps->transform_8x8_mode_flag = read_bits(buf, 1); diff --git a/src/libvdpau/nal.h b/src/libvdpau/nal.h index ee5a4bb05..f892e1a3a 100644 --- a/src/libvdpau/nal.h +++ b/src/libvdpau/nal.h @@ -87,6 +87,32 @@ enum aspect_ratio ASPECT_EXTENDED_SAR=255 }; +static const uint8_t zigzag_4x4[16] = { + 0+0*4, 1+0*4, 0+1*4, 0+2*4, + 1+1*4, 2+0*4, 3+0*4, 2+1*4, + 1+2*4, 0+3*4, 1+3*4, 2+2*4, + 3+1*4, 3+2*4, 2+3*4, 3+3*4, +}; + +static const uint8_t zigzag_8x8[64] = { + 0+0*8, 1+0*8, 0+1*8, 0+2*8, + 1+1*8, 2+0*8, 3+0*8, 2+1*8, + 1+2*8, 0+3*8, 0+4*8, 1+3*8, + 2+2*8, 3+1*8, 4+0*8, 5+0*8, + 4+1*8, 3+2*8, 2+3*8, 1+4*8, + 0+5*8, 0+6*8, 1+5*8, 2+4*8, + 3+3*8, 4+2*8, 5+1*8, 6+0*8, + 7+0*8, 6+1*8, 5+2*8, 4+3*8, + 3+4*8, 2+5*8, 1+6*8, 0+7*8, + 1+7*8, 2+6*8, 3+5*8, 4+4*8, + 5+3*8, 6+2*8, 7+1*8, 7+2*8, + 6+3*8, 5+4*8, 4+5*8, 3+6*8, + 2+7*8, 3+7*8, 4+6*8, 5+5*8, + 6+4*8, 7+3*8, 7+4*8, 6+5*8, + 5+6*8, 4+7*8, 5+7*8, 6+6*8, + 7+5*8, 7+6*8, 6+7*8, 7+7*8, +}; + static inline uint32_t slice_type(uint32_t slice_type) { return (slice_type < 10 ? slice_type % 5 : slice_type); diff --git a/src/libvdpau/vdpau_h264.c b/src/libvdpau/vdpau_h264.c index e351ba8cc..9060ad1c1 100644 --- a/src/libvdpau/vdpau_h264.c +++ b/src/libvdpau/vdpau_h264.c @@ -123,22 +123,22 @@ static inline void dump_pictureinfo_h264(VdpPictureInfoH264 *pic) /*int i, j; for(i = 0; i < 6; i++) { - printf("scalint_list4x4[%d]: ", i); + printf("C: scalint_list4x4[%d]:\nC:", i); for(j = 0; j < 16; j++) { - printf("[%d] ", pic->scaling_lists_4x4[i][j]); + printf(" [%d]", pic->scaling_lists_4x4[i][j]); if(j%8 == 0) - printf("\n"); + printf("\nC:"); } - printf("\n"); + printf("C: \n"); } for(i = 0; i < 2; i++) { - printf("scalint_list4x4[%d]: ", i); + printf("C: scalint_list8x8[%d]:\nC:", i); for(j = 0; j < 64; j++) { - printf("[%d] ", pic->scaling_lists_4x4[i][j]); + printf(" [%d] ", pic->scaling_lists_8x8[i][j]); if(j%8 == 0) - printf("\n"); + printf("\nC:"); } - printf("\n"); + printf("C: \n"); }*/ int i; @@ -262,8 +262,9 @@ static void fill_vdpau_pictureinfo_h264(video_decoder_t *this_gen, uint32_t slic pic->pic_order_present_flag = pps->pic_order_present_flag; pic->deblocking_filter_control_present_flag = pps->deblocking_filter_control_present_flag; pic->redundant_pic_cnt_present_flag = pps->redundant_pic_cnt_present_flag; - memcpy(pic->scaling_lists_4x4, sps->scaling_lists_4x4, sizeof(pic->scaling_lists_4x4)); - memcpy(pic->scaling_lists_8x8, sps->scaling_lists_8x8, sizeof(pic->scaling_lists_8x8)); + + memcpy(pic->scaling_lists_4x4, pps->scaling_lists_4x4, sizeof(pic->scaling_lists_4x4)); + memcpy(pic->scaling_lists_8x8, pps->scaling_lists_8x8, sizeof(pic->scaling_lists_8x8)); /* set num_ref_frames to the number of actually available reference frames, * if this is not set generation 3 decoders will fail. */ |