summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libvdpau/Makefile.am12
-rw-r--r--src/libvdpau/nal_parser.c49
-rw-r--r--src/libvdpau/nal_parser.h39
-rw-r--r--src/libvdpau/vdpau_h264.c28
4 files changed, 58 insertions, 70 deletions
diff --git a/src/libvdpau/Makefile.am b/src/libvdpau/Makefile.am
index 9fb5527bf..31afca222 100644
--- a/src/libvdpau/Makefile.am
+++ b/src/libvdpau/Makefile.am
@@ -3,15 +3,13 @@ include $(top_srcdir)/misc/Makefile.common
AM_CFLAGS = $(VISIBILITY_FLAG)
AM_LDFLAGS = $(xineplug_ldflags)
-EXTRA_DIST = vdpau_h264.c
-
if HAVE_VDPAU
vdpau_h264_module = xineplug_decode_vdpau_h264.la
+VDPAU_CFLAGS = -D_ISOC99_SOURCE
endif
-xineplug_LTLIBRARIES = $(vdpau_h264_module) \
- xineplug_decode_vdpau_h264.la \
+xineplug_LTLIBRARIES = $(vdpau_h264_module)
-xineplug_decode_image_la_SOURCES = nal_parser.c vdpau_h264.c
-xineplug_decode_image_la_CFLAGS = $(AM_CFLAGS) $(WAND_CFLAGS)
-xineplug_decode_image_la_LIBADD = $(XINE_LIB) $(DYNAMIC_LD_LIBS) $(WAND_LIBS)
+xineplug_decode_vdpau_h264_la_SOURCES = nal_parser.c vdpau_h264.c
+xineplug_decode_vdpau_h264_la_CFLAGS = $(AM_CFLAGS) $(VDPAU_CFLAGS)
+xineplug_decode_vdpau_h264_la_LIBADD = $(XINE_LIB) $(DYNAMIC_LD_LIBS)
diff --git a/src/libvdpau/nal_parser.c b/src/libvdpau/nal_parser.c
index 8b3265337..7422bd118 100644
--- a/src/libvdpau/nal_parser.c
+++ b/src/libvdpau/nal_parser.c
@@ -4,6 +4,26 @@
#include "nal_parser.h"
+/* default scaling_lists according to Table 7-2 */
+uint8_t default_4x4_intra[16] =
+ { 6, 13, 13, 20, 20, 20, 28, 28, 28, 28, 32, 32, 32, 37, 37, 42 };
+
+uint8_t default_4x4_inter[16] =
+ { 10, 14, 14, 20, 20, 20, 24, 24, 24, 24, 27, 27, 27, 30, 30, 34};
+
+uint8_t default_8x8_intra[64] =
+ { 6, 10, 10, 13, 11, 13, 16, 16, 16, 16, 18, 18, 18, 18, 18, 32,
+ 23, 23, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 27, 27, 27, 27,
+ 27, 27, 27, 27, 29, 29, 29, 29, 29, 29, 29, 31, 31, 31, 31, 31,
+ 31, 33, 33, 33, 33, 33, 36, 36, 36, 36, 38, 38, 38, 40, 40, 42 };
+
+uint8_t default_8x8_inter[64] =
+ { 9, 13, 13, 15, 13, 15, 17, 17, 17, 17, 19, 19, 19, 19, 19, 21,
+ 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 24, 24, 24, 24,
+ 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 27, 27, 27, 27, 27,
+ 27, 28, 28, 28, 28, 28, 30, 30, 30, 30, 32, 32, 32, 33, 33, 35 };
+
+
struct buf_reader {
uint8_t *buf;
uint8_t *cur_pos;
@@ -15,6 +35,7 @@ static inline uint32_t read_bits(struct buf_reader *buf, int len);
uint32_t read_exp_golomb(struct buf_reader *buf);
int32_t read_exp_golomb_s(struct buf_reader *buf);
void skip_scaling_list(struct buf_reader *buf, int size);
+void parse_scaling_list(struct buf_reader *buf, uint8_t *scaling_list, int length, int index);
int parse_nal_header(struct buf_reader *buf, struct nal_unit *nal);
uint8_t parse_sps(struct buf_reader *buf, struct seq_parameter_set_rbsp *sps);
uint8_t parse_pps(struct buf_reader *buf, struct pic_parameter_set_rbsp *pps);
@@ -105,8 +126,8 @@ static inline uint8_t rbsp_trailing_bits(struct buf_reader *buf)
uint8_t rbsp_trailing_bits = 1;
- offset = buf->cur_offset;
- pos = buf->cur_pos;
+ last_offset = buf->cur_offset;
+ last_pos = buf->cur_pos;
if(read_bits(buf, 1) == 1)
{
@@ -116,8 +137,8 @@ static inline uint8_t rbsp_trailing_bits(struct buf_reader *buf)
}
// revert buffer
- buf->cur_offset = offset;
- buf->cur_pos = pos;
+ buf->cur_offset = last_offset;
+ buf->cur_pos = last_pos;
return rbsp_trailing_bits;
}
@@ -225,8 +246,8 @@ void parse_scaling_list(struct buf_reader *buf, uint8_t *scaling_list, int lengt
break;
}
}
- scaling_list = (next_scale == 0) ? last_scale : next_scale;
- last_scale = scaling_list->scaling_list[i];
+ scaling_list[i] = (next_scale == 0) ? last_scale : next_scale;
+ last_scale = scaling_list[i];
}
if(use_default_scaling_matrix_flag) {
@@ -234,18 +255,18 @@ void parse_scaling_list(struct buf_reader *buf, uint8_t *scaling_list, int lengt
case 0:
case 1:
case 2:
- memcpy(scaling_list, length, default_4x4_intra);
+ memcpy(scaling_list, default_4x4_intra, length);
break;
case 3:
case 4:
case 5:
- memcpy(scaling_list, length, default_4x4_inter);
+ memcpy(scaling_list, default_4x4_inter, length);
break;
case 6:
- memcpy(scaling_list, length, default_8x8_intra);
+ memcpy(scaling_list, default_8x8_intra, length);
break;
case 7:
- memcpy(scaling_list, length, default_8x8_inter);
+ memcpy(scaling_list, default_8x8_inter, length);
break;
}
}
@@ -341,7 +362,7 @@ uint8_t parse_pps(struct buf_reader *buf, struct pic_parameter_set_rbsp *pps)
pps->entropy_coding_mode_flag = read_bits(buf, 1);
pps->pic_order_present_flag = read_bits(buf, 1);
- pps->num_slice_groups_minus1 = read_exp_golomp(buf);
+ pps->num_slice_groups_minus1 = read_exp_golomb(buf);
if(pps->num_slice_groups_minus1 > 0) {
pps->slice_group_map_type = read_exp_golomb(buf);
if(pps->slice_group_map_type == 0) {
@@ -364,7 +385,7 @@ uint8_t parse_pps(struct buf_reader *buf, struct pic_parameter_set_rbsp *pps)
int i_group;
for(i_group = 0; i_group <= pps->num_slice_groups_minus1; i_group++) {
pps->slice_group_id[i_group] =
- read_bits(buf, ceil(log2(pps->num_slice_groups_minus1 + 1)));
+ read_bits(buf, ceil(log(pps->num_slice_groups_minus1 + 1)));
}
}
}
@@ -372,7 +393,7 @@ uint8_t parse_pps(struct buf_reader *buf, struct pic_parameter_set_rbsp *pps)
pps->num_ref_idx_l0_active_minus1 = read_exp_golomb(buf);
pps->num_ref_idx_l1_active_minus1 = read_exp_golomb(buf);
pps->weighted_pred_flag = read_bits(buf, 1);
- pps->weighted_bipred_flag = read_bits(buf, 2);
+ pps->weighted_bipred_idc = read_bits(buf, 2);
pps->pic_init_qp_minus26 = read_exp_golomb_s(buf);
pps->pic_init_qs_minus26 = read_exp_golomb_s(buf);
pps->chroma_qp_index_offset = read_exp_golomb_s(buf);
@@ -478,7 +499,7 @@ void free_parser(struct nal_parser *parser)
}
int parse_frame(struct nal_parser *parser, uint8_t *inbuf, int inbuf_len,
- uint8_t **ret_buf, int *ret_len, int *ret_slice_cnt)
+ uint8_t **ret_buf, uint32_t *ret_len, uint32_t *ret_slice_cnt)
{
int next_nal;
int parsed_len = 0;
diff --git a/src/libvdpau/nal_parser.h b/src/libvdpau/nal_parser.h
index 7a3c4726a..fed12ff0d 100644
--- a/src/libvdpau/nal_parser.h
+++ b/src/libvdpau/nal_parser.h
@@ -22,26 +22,6 @@ enum nal_unit_types {
NAL_SPS_EXT
};
-/* default scaling_lists according to Table 7-2 */
-uint8_t default_4x4_intra[16] =
- { 6, 13, 13, 20, 20, 20, 28, 28, 28, 28, 32, 32, 32, 37, 37, 42 };
-
-uint8_t default_4x4_inter[16] =
- { 10, 14, 14, 20, 20, 20, 24, 24, 24, 24, 27, 27, 27, 30, 30, 34};
-
-uint8_t default_8x8_intra[64] =
- { 6, 10, 10, 13, 11, 13, 16, 16, 16, 16, 18, 18, 18, 18, 18, 32,
- 23, 23, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 27, 27, 27, 27,
- 27, 27, 27, 27, 29, 29, 29, 29, 29, 29, 29, 31, 31, 31, 31, 31,
- 31, 33, 33, 33, 33, 33, 36, 36, 36, 36, 38, 38, 38, 40, 40, 42 };
-
-uint8_t default_8x8_inter[64] =
- { 9, 13, 13, 15, 13, 15, 17, 17, 17, 17, 19, 19, 19, 19, 19, 21,
- 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 24, 24, 24, 24,
- 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 27, 27, 27, 27, 27,
- 27, 28, 28, 28, 28, 28, 30, 30, 30, 30, 32, 32, 32, 33, 33, 35 };
-
-
struct nal_unit {
uint8_t nal_ref_idc; // 0x03
uint8_t nal_unit_type; // 0x1f
@@ -64,12 +44,11 @@ struct seq_parameter_set_rbsp {
uint8_t seq_scaling_matrix_present_flag;
/* if(seq_scaling_matrix_present_flag) */
- {
uint8_t seq_scaling_list_present_flag[8];
uint8_t scaling_lists_4x4[6][16];
uint8_t scaling_lists_8x8[2][64];
- }
+ /* endif */
uint32_t log2_max_frame_num_minus4;
uint32_t pic_order_cnt_type;
@@ -110,32 +89,22 @@ struct pic_parameter_set_rbsp {
uint32_t num_slice_groups_minus1;
/* num_slice_groups_minus1 > 0 */
- {
- uint32_t slice_group_map_type;
+ uint32_t slice_group_map_type;
/* slice_group_map_type == 1 */
- {
uint32_t run_length_minus1[64];
- }
/* slice_group_map_type == 2 */
- {
uint32_t top_left[64];
uint32_t bottom_right[64];
- }
/* slice_group_map_type == 3,4,5 */
- {
uint8_t slice_group_change_direction_flag;
uint32_t slice_group_change_rate_minus1;
- }
/* slice_group_map_type == 6 */
- {
uint32_t pic_size_in_map_units_minus1;
uint8_t slice_group_id[64];
- }
- }
uint32_t num_ref_idx_l0_active_minus1;
uint32_t num_ref_idx_l1_active_minus1;
@@ -153,14 +122,12 @@ struct pic_parameter_set_rbsp {
uint8_t pic_scaling_matrix_present_flag;
/* if(pic_scaling_matrix_present_flag) */
- {
uint8_t pic_scaling_list_present_flag[8];
uint8_t scaling_lists_4x4[6][16];
uint8_t scaling_lists_8x8[2][64];
int32_t second_chroma_qp_index_offset;
- }
};
struct slice_header {
@@ -211,6 +178,6 @@ int seek_for_nal(uint8_t *buf, int buf_len);
struct nal_parser* init_parser();
void free_parser(struct nal_parser *parser);
int parse_frame(struct nal_parser *parser, uint8_t *inbuf, int inbuf_len,
- uint8_t **ret_buf, int *ret_len);
+ uint8_t **ret_buf, uint32_t *ret_len, uint32_t *ret_slice_cnt);
#endif
diff --git a/src/libvdpau/vdpau_h264.c b/src/libvdpau/vdpau_h264.c
index afd4561c6..76612168b 100644
--- a/src/libvdpau/vdpau_h264.c
+++ b/src/libvdpau/vdpau_h264.c
@@ -37,6 +37,7 @@
#include "xineutils.h"
#include "bswap.h"
#include "accel_vdpau.h"
+#include "nal_parser.h"
#define VIDEOBUFSIZE 128*1024
@@ -67,11 +68,13 @@ typedef struct vdpau_h264_decoder_s {
struct nal_parser *nal_parser; /* h264 nal parser. extracts stream data for vdpau */
+ VdpDecoder decoder;
+
VdpDecoderProfile profile;
VdpPictureInfoH264 vdp_picture_info;
vdpau_accel_t *vdpau_accel;
- xine_t *xine
+ xine_t *xine;
} vdpau_h264_decoder_t;
@@ -113,10 +116,11 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
if (!this->decoder_ok) {
/* parse the first nal packages to retrieve profile type */
int len = 0;
+ uint32_t slice_count;
while(len < buf->size) {
- len += parse_frame(this->parser, buf->content + len, buf->size - len,
- &vdp_buffer.bitstream, &vdp_buffer.bitstream_bytes);
+ len += parse_frame(this->nal_parser, buf->content + len, buf->size - len,
+ (void*)&vdp_buffer.bitstream, &vdp_buffer.bitstream_bytes, &slice_count);
if(this->nal_parser->current_nal->sps != NULL) {
printf("SPS PARSED\n");
@@ -151,21 +155,20 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
this->vdpau_accel = (vdpau_accel_t*)img->accel_data;
- VdpBool is_supported;
- uint32_t max_level, max_references, max_width, max_height;
+ /*VdpBool is_supported;
+ uint32_t max_level, max_references, max_width, max_height;*/
VdpStatus status = this->vdpau_accel->vdp_decoder_create(this->vdpau_accel->vdp_device,
- this->profile, &is_supported, &max_level, &max_references,
- &max_width, &max_height);
+ this->profile, this->width, this->height, &this->decoder);
- if(status != OK)
+ if(status != VDP_STATUS_OK)
xprintf(this->xine, XINE_VERBOSITY_LOG, "vdpau_h264: ERROR: VdpDecoderCreate returned status != OK (%d)\n", status);
- if(!is_supported)
+ /*if(!is_supported)
xprintf(this->xine, XINE_VERBOSITY_LOG, "vdpau_h264: ERROR: Profile not supported by VDPAU decoder.\n");
if(max_width < this->width || max_height < this->height)
- xprintf(this->xine, XINE_VERBOSITY_LOG, "vdpau_h264: ERROR: Image size not supported by VDPAU decoder.\n");
+ xprintf(this->xine, XINE_VERBOSITY_LOG, "vdpau_h264: ERROR: Image size not supported by VDPAU decoder.\n");*/
}
}
@@ -194,9 +197,8 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
img->pts = buf->pts;
img->bad_frame = 0;
- memset(img->base[0], this->current_yuv_byte,
+ memset(img->base[0], 0,
this->width * this->height * 2);
- this->current_yuv_byte += 3;
img->draw(img, this->stream);
img->free(img);
@@ -260,7 +262,7 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stre
this = (vdpau_h264_decoder_t *) calloc(1, sizeof(vdpau_h264_decoder_t));
/* the videoout must be vdpau-capable to support this decoder */
- if(!stream->video_driver->get_capabilities() & VO_CAP_VDPAU_H264)
+ if(!stream->video_driver->get_capabilities(stream->video_driver) & VO_CAP_VDPAU_H264)
return NULL;
this->video_decoder.decode_data = vdpau_h264_decode_data;