v4l2: use codec descriptors for mapping a codec name to id
authorAnton Khirnov <anton@khirnov.net>
Wed, 14 Dec 2016 12:22:19 +0000 (13:22 +0100)
committerAnton Khirnov <anton@khirnov.net>
Mon, 19 Dec 2016 07:07:15 +0000 (08:07 +0100)
This mapping has nothing to do with decoder implementations, so using
decoder names is wrong.

libavdevice/v4l2.c

index 0479121..a8afe8a 100644 (file)
@@ -771,16 +771,16 @@ static int v4l2_read_header(AVFormatContext *s1)
     }
 
     if (s->pixel_format) {
-        AVCodec *codec = avcodec_find_decoder_by_name(s->pixel_format);
+        const AVCodecDescriptor *desc = avcodec_descriptor_get_by_name(s->pixel_format);
 
-        if (codec) {
-            s1->video_codec_id = codec->id;
+        if (desc) {
+            s1->video_codec_id = desc->id;
             st->need_parsing   = AVSTREAM_PARSE_HEADERS;
         }
 
         pix_fmt = av_get_pix_fmt(s->pixel_format);
 
-        if (pix_fmt == AV_PIX_FMT_NONE && !codec) {
+        if (pix_fmt == AV_PIX_FMT_NONE && !desc) {
             av_log(s1, AV_LOG_ERROR, "No such input format: %s.\n",
                    s->pixel_format);