Go Back   nV News Forums > Linux Support Forums > NVIDIA Linux

Newegg Daily Deals

Reply
 
Thread Tools
Old 12-27-11, 08:06 AM   #1
LordSauron
Registered User
 
Join Date: Dec 2011
Posts: 2
Default VDPAU and H264, gray screen

Hi everyone,

I'm developing an Intra H264 encoder and one of the features is to use VDPAU for previewing.
When I get the bitstream from the encoder I simply extract the pps, sps and slice NALs, and give the parameters to my VDPAU functions. But I only get a gray screen.
It works perfectly when I use a "put bits" function to preview the original YUV sequence.
I paste here part of my code and the VDPAU trace. I attach also the nVidia log and I've uploaded to your sftp an encoded frame with the name "h264_1frame.264" (I take from it the parameters for the VDPAU functions).

What I'm doing wrong?

Thanks.

Note: the encoded frame probably will not be playable by most of the players, but I've not found the error yet. It's just a problem with the first frame. But ffmpeg can decode it, so I don't guess the problem with the players (even MPlayer). Anyway, it shouldn't be a problem for my VDPAU functions.

My code
Code:
void create(int width, int height){

   vdp_presentation_queue_target_create_x11(vdpDevice, winID, &vdpQueueTarget);

   vdp_presentation_queue_create(vdpDevice, vdpQueueTarget, &vdpQueue);

   vdp_output_surface_create(vdpDevice, VDP_RGBA_FORMAT_B8G8R8A8, width, height, &vdpOutputSurface);

   chroma2 = VDP_RGBA_FORMAT_B8G8R8A8;
   vdp_video_surface_create(vdpDevice, chroma2, width, height, &vdpVideoSurfaceDecoder);
   VdpVideoMixerParameter vdpVideoMixerParameters[3] = {VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE, VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT, VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH};

   void* parameters[3] = {&chroma2, &height, &width};

   vdp_video_mixer_create(vdpDevice, 0, NULL, 3, vdpVideoMixerParameters, (void const *const *)&parameters, &vdpVideoMixer);

   vdp_decoder_create(vdpDevice, VDP_DECODER_PROFILE_H264_HIGH, width, height, 0, &vdpDecoder);
}

void preview(mystructure* hd){

   vdpBitstreamBuffer.bitstream = (void const*)hd->bs.p_begin_buffer; // It's OK
   vdpBitstreamBuffer.bitstream_bytes = (uint32_t)hd->bs.i_NAL_size; // It's OK
   vdpBitstreamBuffer.struct_version = VDP_BITSTREAM_BUFFER_VERSION;
   fillVdpPictureInfo(hd);
   vdp_decoder_render(vdpDecoder, vdpVideoSurfaceDecoder, (VdpPictureInfo const*)&vdpPictureInfoH264, 1, &vdpBitstreamBuffer);

   vdp_video_mixer_render(vdpVideoMixer, VDP_INVALID_HANDLE, NULL, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME, 0, NULL, vdpVideoSurfaceDecoder, 0, NULL, NULL, vdpOutputSurface, NULL, &vdpPreviewSurfaceRect, 0, NULL);

   VdpTime vdpTime;
   vdp_presentation_queue_get_time(vdpQueue, &vdpTime);

   vdp_presentation_queue_display(vdpQueue, vdpOutputSurface, 0, 0, vdpTime);

}

static void fillVdpPictureInfo(mystructure* hd){
    memcpy(vdpPictureInfoH264.field_order_cnt, hd->sh.i_delta_poc, sizeof(hd->sh.i_delta_poc));
    vdpPictureInfoH264.frame_num = hd->sh.i_frame_num;
    vdpPictureInfoH264.field_pic_flag = hd->sh.b_field_pic;
    vdpPictureInfoH264.bottom_field_flag = hd->sh.b_bottom_field;
    vdpPictureInfoH264.num_ref_frames = hd->sps.i_num_ref_frames;
    vdpPictureInfoH264.mb_adaptive_frame_field_flag = hd->sps.b_mb_adaptive_frame_field;
    vdpPictureInfoH264.constrained_intra_pred_flag = hd->pps.b_constrained_intra_pred;
    vdpPictureInfoH264.weighted_pred_flag = hd->pps.b_weighted_pred;
    vdpPictureInfoH264.weighted_bipred_idc = hd->pps.b_weighted_bipred;
    vdpPictureInfoH264.frame_mbs_only_flag = hd->sps.b_frame_mbs_only;
    vdpPictureInfoH264.transform_8x8_mode_flag = hd->pps.b_transform_8x8_mode;
    vdpPictureInfoH264.chroma_qp_index_offset = hd->pps.i_chroma_qp_index_offset;
    vdpPictureInfoH264.second_chroma_qp_index_offset = hd->pps.i_chroma_qp_index_offset;
    vdpPictureInfoH264.pic_init_qp_minus26 = hd->pps.i_pic_init_qp; // -26
    vdpPictureInfoH264.num_ref_idx_l0_active_minus1 = hd->pps.i_num_ref_idx_l0_active; // -1
    vdpPictureInfoH264.num_ref_idx_l1_active_minus1 = hd->pps.i_num_ref_idx_l1_active; // -1
    vdpPictureInfoH264.log2_max_frame_num_minus4 = hd->sps.i_log2_max_frame_num; // -4
    vdpPictureInfoH264.pic_order_cnt_type = hd->sps.i_poc_type;
    vdpPictureInfoH264.log2_max_pic_order_cnt_lsb_minus4 = hd->sps.i_log2_max_poc_lsb; // -4
    vdpPictureInfoH264.delta_pic_order_always_zero_flag = hd->sps.b_delta_pic_order_always_zero;
    vdpPictureInfoH264.direct_8x8_inference_flag = hd->sps.b_direct8x8_inference;
    vdpPictureInfoH264.entropy_coding_mode_flag = hd->pps.b_entropy_coding_mode;
    vdpPictureInfoH264.pic_order_present_flag = hd->pps.b_pic_order; // botom_field_pic_order_in_frame_present_flag
    vdpPictureInfoH264.deblocking_filter_control_present_flag = hd->pps.b_deblocking_filter_control;
    vdpPictureInfoH264.redundant_pic_cnt_present_flag = hd->pps.b_redundant_pic_cnt;
    memcpy(vdpPictureInfoH264.scaling_lists_4x4, hd->pps.scaling_list, sizeof(hd->pps.scaling_list));
    memcpy(vdpPictureInfoH264.scaling_lists_8x8, hd->pps.scaling_list, sizeof(hd->pps.scaling_list));

    vdpPictureInfoH264.slice_count = 1;
    vdpPictureInfoH264.is_reference = VDP_FALSE;

   /* Is an Intra encoder, so I don't have reference frames */
    vdpReferenceFrameH264.surface = VDP_INVALID_HANDLE;
    vdpReferenceFrameH264.is_long_term = VDP_FALSE;
    vdpReferenceFrameH264.top_is_reference = VDP_FALSE;
    vdpReferenceFrameH264.bottom_is_reference = VDP_FALSE;
    memcpy(vdpReferenceFrameH264.field_order_cnt, hd->sh.i_delta_poc, sizeof(hd->sh.i_delta_poc));
    vdpReferenceFrameH264.frame_idx = hd->sh.i_frame_num;
    int i;
    for(i=0;i<16;i++)
        vdpPictureInfoH264.referenceFrames[i] = vdpReferenceFrameH264;
}
VDPAU trace
Code:
VDPAU capture: Enabled
vdp_imp_device_create_x11(0x1bc8470, 0, -, -)
    -> 0, 1, 0x7f8600a34940
vdp_get_proc_address(1, 18, -)
    -> 0, 0x7f8600822120
vdp_get_proc_address(1, 19, -)
    -> 0, 0x7f860081fcc0
vdp_get_proc_address(1, 24, -)
    -> 0, 0x7f86008279c0
vdp_get_proc_address(1, 33, -)
    -> 0, 0x7f8600826d00
vdp_get_proc_address(1, 9, -)
    -> 0, 0x7f86008229e0
vdp_get_proc_address(1, 10, -)
    -> 0, 0x7f860081fd60
vdp_get_proc_address(1, 13, -)
    -> 0, 0x7f86008274b0
vdp_get_proc_address(1, 46, -)
    -> 0, 0x7f8600824330
vdp_get_proc_address(1, 53, -)
    -> 0, 0x7f860081fae0
vdp_get_proc_address(1, 41, -)
    -> 0, 0x7f86008212a0
vdp_get_proc_address(1, 42, -)
    -> 0, 0x7f8600821180
vdp_get_proc_address(1, 43, -)
    -> 0, 0x7f8600821060
vdp_get_proc_address(1, 54, -)
    -> 0, 0x7f8600826580
vdp_get_proc_address(1, 37, -)
    -> 0, 0x7f86008215a0
vdp_get_proc_address(1, 38, -)
    -> 0, 0x7f860081fb80
vdp_get_proc_address(1, 40, -)
    -> 0, 0x7f8600823390
vdp_get_proc_address(1, 4096, -)
    -> 0, 0x7f8600820a70
vdp_get_proc_address(1, 55, -)
    -> 0, 0x7f860081fa40
vdp_get_proc_address(1, 56, -)
    -> 0, 0x7f8600820f40
vdp_get_proc_address(1, 57, -)
    -> 0, 0x7f860081f9a0
vdp_get_proc_address(1, 62, -)
    -> 0, 0x7f8600820e30
vdp_get_proc_address(1, 63, -)
    -> 0, 0x7f860081f8b0
vdp_presentation_queue_target_create_x11(1, 79691777, -)
    -> 0, 2
vdp_presentation_queue_create(1, 2, -)
    -> 0, 3
vdp_output_surface_create(1, 0, 1280, 720, -)
    -> 0, 4
vdp_video_surface_create(1, 0, 1280, 720, -)
    -> 0, 5
vdp_video_mixer_create(1, 0, NULL, 3, {2, 1, 0}, {0, 720, 1280}, -)
    -> 0, 6
vdp_decoder_create(1, 8, 1280, 720, 0, -)
    -> 0, 7
vdp_decoder_render(7, 5, {1, {0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, -16, 0, 0, 1, 0, 2, 0, 1, 0, 0, 1, 0, {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, {{4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}, {4294967295, 0, 0, 0, {0, 0}, 0}}}, 1, {{(ver 0) 693119, ...}})
    -> 0
vdp_video_mixer_render(6, 4294967295, NULL, 2, 0, NULL, 5, 0, NULL, NULL, 4, NULL, {0, 0, 1258, 583}, 0, NULL)
    -> 0
vdp_presentation_queue_get_time(3, -)
    -> 0, 1324977648524690080
vdp_presentation_queue_display(3, 4, 0, 0, 1324977648524690080)
    -> 0
vdp_decoder_destroy(7)
    -> 0
vdp_video_mixer_destroy(6)
    -> 0
vdp_video_surface_destroy(5)
    -> 0
vdp_presentation_queue_destroy(3)
    -> 0
vdp_presentation_queue_target_destroy(2)
    -> 0
Attached Files
File Type: gz nvidia-bug-report.log.gz (87.2 KB, 35 views)
LordSauron is offline   Reply With Quote
Old 12-29-11, 06:23 AM   #2
LordSauron
Registered User
 
Join Date: Dec 2011
Posts: 2
Default Re: VDPAU and H264, gray screen

I've fixed the problem.
It was the scaling matrix. Since it was constant it's not sent in the bitstream so the pointers I got were null.

Replacing with this code is enough:
Code:
const uint8_t scaling_list_4x4[6][16]={
    {16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16},
    {16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16},
    {16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16},
    {16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16},
    {16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16},
    {16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16}
};
const uint8_t scaling_list_8x8[2][64]={
    {16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
    16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
    16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
    16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16},
    {16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
    16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
    16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
    16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16}
};

memcpy(vdpPictureInfoH264.scaling_lists_4x4, scaling_list_4x4, sizeof(vdpPictureInfoH264.scaling_lists_4x4));
memcpy(vdpPictureInfoH264.scaling_lists_8x8, scaling_list_8x8, sizeof(vdpPictureInfoH264.scaling_lists_8x8));
Thanks anyway. You can close the thread.
Regards.
LordSauron is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:37 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.