[FFmpeg-cvslog] Merge commit '0fea8555ae25124c21f4c4f55a5fa76e9169aa03'
Clément Bœsch
git at videolan.org
Wed Apr 26 18:20:48 EEST 2017
ffmpeg | branch: master | Clément Bœsch <u at pkh.me> | Wed Apr 26 17:17:50 2017 +0200| [a0ffd66caaae1bff1abebffb36e135abcc8122e6] | committer: Clément Bœsch
Merge commit '0fea8555ae25124c21f4c4f55a5fa76e9169aa03'
* commit '0fea8555ae25124c21f4c4f55a5fa76e9169aa03':
v4l2: use codec descriptors for mapping a codec name to id
Merged-by: Clément Bœsch <u at pkh.me>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a0ffd66caaae1bff1abebffb36e135abcc8122e6
---
libavdevice/v4l2.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 15629755a1..17451cdb60 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -884,14 +884,14 @@ static int v4l2_read_header(AVFormatContext *ctx)
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
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)
- ctx->video_codec_id = codec->id;
+ if (desc)
+ ctx->video_codec_id = desc->id;
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(ctx, AV_LOG_ERROR, "No such input format: %s.\n",
s->pixel_format);
======================================================================
diff --cc libavdevice/v4l2.c
index 15629755a1,a8afe8ab58..17451cdb60
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@@ -841,62 -756,35 +841,62 @@@ static int v4l2_read_header(AVFormatCon
if (s->fd < 0)
return s->fd;
- if (s->list_format) {
- list_formats(s1, s->fd, s->list_format);
- return AVERROR_EXIT;
+ if (s->channel != -1) {
+ /* set video input */
+ av_log(ctx, AV_LOG_DEBUG, "Selecting input_channel: %d\n", s->channel);
+ if (v4l2_ioctl(s->fd, VIDIOC_S_INPUT, &s->channel) < 0) {
+ res = AVERROR(errno);
+ av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_S_INPUT): %s\n", av_err2str(res));
+ goto fail;
+ }
+ } else {
+ /* get current video input */
+ if (v4l2_ioctl(s->fd, VIDIOC_G_INPUT, &s->channel) < 0) {
+ res = AVERROR(errno);
+ av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_G_INPUT): %s\n", av_err2str(res));
+ goto fail;
+ }
}
- avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
+ /* enum input */
+ input.index = s->channel;
+ if (v4l2_ioctl(s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
+ res = AVERROR(errno);
+ av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMINPUT): %s\n", av_err2str(res));
+ goto fail;
+ }
+ s->std_id = input.std;
+ av_log(ctx, AV_LOG_DEBUG, "Current input_channel: %d, input_name: %s, input_std: %"PRIx64"\n",
+ s->channel, input.name, (uint64_t)input.std);
- if (s->video_size &&
- (res = av_parse_video_size(&s->width, &s->height, s->video_size)) < 0) {
- av_log(s1, AV_LOG_ERROR, "Could not parse video size '%s'.\n",
- s->video_size);
- return res;
+ if (s->list_format) {
+ list_formats(ctx, s->list_format);
+ res = AVERROR_EXIT;
+ goto fail;
}
+ if (s->list_standard) {
+ list_standards(ctx);
+ res = AVERROR_EXIT;
+ goto fail;
+ }
+
+ avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
+
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)
- ctx->video_codec_id = codec->id;
- if (desc) {
- s1->video_codec_id = desc->id;
- st->need_parsing = AVSTREAM_PARSE_HEADERS;
- }
++ if (desc)
++ ctx->video_codec_id = desc->id;
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",
+ av_log(ctx, AV_LOG_ERROR, "No such input format: %s.\n",
s->pixel_format);
- return AVERROR(EINVAL);
+ res = AVERROR(EINVAL);
+ goto fail;
}
}
More information about the ffmpeg-cvslog
mailing list