applemedia: vtdec: set the correct video format in the video meta
authorAlessandro Decina <alessandro.d@gmail.com>
Tue, 10 Dec 2013 10:10:54 +0000 (11:10 +0100)
committerAlessandro Decina <alessandro.d@gmail.com>
Tue, 10 Dec 2013 10:12:56 +0000 (11:12 +0100)
Fixes all kinds of weird bugs when videoconvert is used with the decoder.

sys/applemedia/corevideobuffer.c
sys/applemedia/vtdec.c

index 35faf3b..ed13bd1 100644 (file)
@@ -102,10 +102,9 @@ gst_core_video_buffer_new (CVBufferRef cvbuf, GstVideoInfo * vinfo)
     for (i = 0; i < n_planes; ++i)
       stride[i] = CVPixelBufferGetBytesPerRowOfPlane (pixbuf, i);
 
-    /* FIXME: don't hardcode NV12 */
     gst_video_info_init (&tmp_vinfo);
     gst_video_info_set_format (&tmp_vinfo,
-        GST_VIDEO_FORMAT_NV12, stride[0], height);
+        vinfo->finfo->format, stride[0], height);
     offset[1] = tmp_vinfo.offset[1];
     size = tmp_vinfo.size;
   } else {
@@ -124,7 +123,7 @@ gst_core_video_buffer_new (CVBufferRef cvbuf, GstVideoInfo * vinfo)
     width = vinfo->width;
     video_meta =
         gst_buffer_add_video_meta_full (buf, GST_VIDEO_FRAME_FLAG_NONE,
-        GST_VIDEO_FORMAT_NV12, width, height, n_planes, offset, stride);
+        vinfo->finfo->format, width, height, n_planes, offset, stride);
   }
 
   return buf;
index 392c17a..7442906 100644 (file)
@@ -490,6 +490,7 @@ gst_vtdec_session_output_callback (void *decompression_output_ref_con,
   GstVtdec *vtdec = (GstVtdec *) decompression_output_ref_con;
   GstVideoCodecFrame *frame = (GstVideoCodecFrame *) source_frame_ref_con;
   GstBuffer *buf;
+  GstVideoCodecState *state;
 
   GST_LOG_OBJECT (vtdec, "got output frame %p %d", frame,
       frame->decode_frame_number);
@@ -503,7 +504,9 @@ gst_vtdec_session_output_callback (void *decompression_output_ref_con,
     goto drop;
 
   /* FIXME: use gst_video_decoder_allocate_output_buffer */
-  buf = gst_core_video_buffer_new (image_buffer, &vtdec->video_info);
+  state = gst_video_decoder_get_output_state (GST_VIDEO_DECODER (vtdec));
+  buf = gst_core_video_buffer_new (image_buffer, &state->info);
+  gst_video_codec_state_unref (state);
   frame->output_buffer = buf;
 
   gst_buffer_copy_into (buf, frame->input_buffer,