[FFmpeg-devel] [PATCHv3 4/4] libavcodec: v4l2: add support for v4l2 mem2mem codecs

Martin Storsjö martin at martin.st
Tue Aug 8 11:23:43 EEST 2017


Hi Jorge,

On Mon, 7 Aug 2017, Jorge Ramirez wrote:

> On 08/03/2017 01:53 AM, Mark Thompson wrote:
>>> +    default:
>>> +        return 0;
>>> +    }
>>> +
>>> +    SET_V4L_EXT_CTRL(value, qmin, avctx->qmin, "minimum video quantizer 
> scale");
>>> +    SET_V4L_EXT_CTRL(value, qmax, avctx->qmax, "maximum video quantizer 
> scale");
>>> +
>>> +    return 0;
>>> +}
>> This doesn't set extradata - you need to extract the codec global headers 
> (such as H.264 SPS and PPS) at init time to be able to write correct files 
> for some codecs (such as H.264) with muxers requiring global headers (such as 
> MP4).  It kindof works without it, but the files created will not conform and 
> will not be usable on some players.
>>
> ah that might explain some things (when I play back the encoded video 
> the quality is pretty lousy)
> is there already some code I can use as a reference? I might be out of 
> my depth here so any help will be more than welcome

This is exactly the thing I was trying to tell you about, off list, 
before.

In the OMX driver used on android, this is requested on startup, via an 
ioctl with the following private ioctl value:
V4L2_CID_MPEG_VIDC_VIDEO_REQUEST_SEQ_HEADER

See this code here:
https://android.googlesource.com/platform/hardware/qcom/media/+/63abe022/msm8996/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp#2991

This is a qcom specific, private ioctl. In the android kernel for 
qualcomm, this is handled correctly here:

https://android.googlesource.com/kernel/msm/+/android-7.1.2_r0.33/drivers/media/platform/msm/vidc/msm_venc.c#2987
https://android.googlesource.com/kernel/msm/+/android-7.1.2_r0.33/drivers/media/platform/msm/vidc/msm_vidc_common.c#3767

In the dragonboard kernel snapshot I had been testing, that I referred to 
you before, there are incomplete stubs of handling of this. In the 
debian-qcom-dragonboard410c-16.04 tag in the linaro kernel tree:

http://git.linaro.org/landing-teams/working/qualcomm/kernel.git/tree/drivers/media/platform/msm/vidc/msm_venc-ctrls.c?h=debian-qcom-dragonboard410c-16.04&id=8205f603ceeb02d08a720676d9075c9e75e47b0f#n2116
This increments seq_hdr_reqs, just like in the android kernel tree (where 
this is working). However in this kernel tree, nothing actually ever reads 
the seq_hdr_reqs, so it's a non-functional stub.

Now in the kernel tree you referred me to, in the 
release/db820c/qcomlt-4.11 branch, I don't see anything similar to 
V4L2_CID_MPEG_VIDC_VIDEO_REQUEST_SEQ_HEADER. I can't help you from there, 
you need to figure that out what alternative codepath there is, intended 
to replace it - if any. If there aren't any, you first need to fix the 
v4l2 driver before userspace apps can get what they need.

There is a clear need for this, as you witness in the android version of 
the kernel. It just seems to have been removed in the vanilla linux 
version of the driver.

// Martin


More information about the ffmpeg-devel mailing list