On 08/25/2017 05:35 PM, wm4 wrote:
+static int buffer_ops_v4l2buf_to_avframe(AVFrame *frame, V4L2Buffer *avbuf)
+{
+ int i, ret;
+
+ av_frame_unref(frame);
+
+ /* 1. get references to the actual data */
+ for (i = 0; i < avbuf->num_planes; i++) {
+ ret = avbuf->ops.buf_to_bufref(avbuf, i, &frame->buf[i]);
+ if (ret)
+ return ret;
+
+ frame->linesize[i] = avbuf->bytesperline[i];
+ frame->data[i] = frame->buf[i]->data;
+ }
+
+ /* 1.1 fixup special cases */
+ switch (avbuf->context->av_pix_fmt) {
+ case AV_PIX_FMT_NV12:
+ if (avbuf->num_planes > 1)
+ break;
+ frame->linesize[1] = avbuf->bytesperline[0];
+ frame->data[1] = frame->buf[0]->data + avbuf->bytesperline[0] *
avbuf->context->format.fmt.pix_mp.height;
+ break;
+ default:
+ break;
+ }
+
+ /* 2. get frame information */
+ frame->key_frame = !!(avbuf->buf.flags & V4L2_BUF_FLAG_KEYFRAME);
+ frame->format = avbuf->context->av_pix_fmt;
+
+ /* these values are updated also during re-init in process_video_event */
+ frame->height = avbuf->context->height;
+ frame->width = avbuf->context->width;
+ frame->pts = get_pts(avbuf);
+
+ /* 3. report errors upstream */
+ if (avbuf->buf.flags & V4L2_BUF_FLAG_ERROR) {
+ av_log(avbuf->context->log_ctx, AV_LOG_ERROR, "%s: driver decode error\n",
avbuf->context->name);
+ frame->decode_error_flags |= FF_DECODE_ERROR_INVALID_BITSTREAM;
+ }
+
+ return 0;
+}
This function seems to lack setting typically required metadata like
colorspace.
ok I will retrieve the colorspace from the v4l2 format structure and set
it in the frame.
is there anything else I am missing?
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel