From 921715edffbba5db8deb26b7ad3cb583ba963d03 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 13 Jun 2011 21:16:30 +0200 Subject: alsa: add support for more formats. Specifically, f32, f64, s32, s24, a-law and mu-law. Signed-off-by: Anton Khirnov --- libavdevice/alsa-audio-common.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libavdevice') diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index ff6c9f875d..4279790ddc 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -36,9 +36,19 @@ static av_cold snd_pcm_format_t codec_id_to_pcm_format(int codec_id) { switch(codec_id) { + case CODEC_ID_PCM_F64LE: return SND_PCM_FORMAT_FLOAT64_LE; + case CODEC_ID_PCM_F64BE: return SND_PCM_FORMAT_FLOAT64_BE; + case CODEC_ID_PCM_F32LE: return SND_PCM_FORMAT_FLOAT_LE; + case CODEC_ID_PCM_F32BE: return SND_PCM_FORMAT_FLOAT_BE; + case CODEC_ID_PCM_S32LE: return SND_PCM_FORMAT_S32_LE; + case CODEC_ID_PCM_S32BE: return SND_PCM_FORMAT_S32_BE; + case CODEC_ID_PCM_S24LE: return SND_PCM_FORMAT_S24_3LE; + case CODEC_ID_PCM_S24BE: return SND_PCM_FORMAT_S24_3BE; case CODEC_ID_PCM_S16LE: return SND_PCM_FORMAT_S16_LE; case CODEC_ID_PCM_S16BE: return SND_PCM_FORMAT_S16_BE; case CODEC_ID_PCM_S8: return SND_PCM_FORMAT_S8; + case CODEC_ID_PCM_MULAW: return SND_PCM_FORMAT_MU_LAW; + case CODEC_ID_PCM_ALAW: return SND_PCM_FORMAT_A_LAW; default: return SND_PCM_FORMAT_UNKNOWN; } } -- cgit v1.2.3 From 2359aeb52d2325ed6c28d4f7579e0999963bcec1 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Thu, 14 Apr 2011 01:04:18 +0200 Subject: alsa: support unsigned variants of already supported signed formats. --- libavdevice/alsa-audio-common.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libavdevice') diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index 4279790ddc..baa6ac79ca 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -42,11 +42,18 @@ static av_cold snd_pcm_format_t codec_id_to_pcm_format(int codec_id) case CODEC_ID_PCM_F32BE: return SND_PCM_FORMAT_FLOAT_BE; case CODEC_ID_PCM_S32LE: return SND_PCM_FORMAT_S32_LE; case CODEC_ID_PCM_S32BE: return SND_PCM_FORMAT_S32_BE; + case CODEC_ID_PCM_U32LE: return SND_PCM_FORMAT_U32_LE; + case CODEC_ID_PCM_U32BE: return SND_PCM_FORMAT_U32_BE; case CODEC_ID_PCM_S24LE: return SND_PCM_FORMAT_S24_3LE; case CODEC_ID_PCM_S24BE: return SND_PCM_FORMAT_S24_3BE; + case CODEC_ID_PCM_U24LE: return SND_PCM_FORMAT_U24_3LE; + case CODEC_ID_PCM_U24BE: return SND_PCM_FORMAT_U24_3BE; case CODEC_ID_PCM_S16LE: return SND_PCM_FORMAT_S16_LE; case CODEC_ID_PCM_S16BE: return SND_PCM_FORMAT_S16_BE; + case CODEC_ID_PCM_U16LE: return SND_PCM_FORMAT_U16_LE; + case CODEC_ID_PCM_U16BE: return SND_PCM_FORMAT_U16_BE; case CODEC_ID_PCM_S8: return SND_PCM_FORMAT_S8; + case CODEC_ID_PCM_U8: return SND_PCM_FORMAT_U8; case CODEC_ID_PCM_MULAW: return SND_PCM_FORMAT_MU_LAW; case CODEC_ID_PCM_ALAW: return SND_PCM_FORMAT_A_LAW; default: return SND_PCM_FORMAT_UNKNOWN; -- cgit v1.2.3 From 147bcf27c4f8b22a386ea626f9455cf3f7cf0410 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 10 Mar 2011 12:10:34 +0100 Subject: ALSA: implement channel layout for playback. Currently quad, 5.0, 5.1 and 7.1 are implemented. Implementing support for other formats/layouts and capture should be straightforward. 5.0 and 7.1 support by Carl Eugen Hoyos. Signed-off-by: Anton Khirnov --- libavdevice/alsa-audio-common.c | 155 ++++++++++++++++++++++++++++++++++++++++ libavdevice/alsa-audio-enc.c | 10 ++- libavdevice/alsa-audio.h | 5 ++ 3 files changed, 169 insertions(+), 1 deletion(-) (limited to 'libavdevice') diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index baa6ac79ca..4cfc6e9864 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -30,6 +30,7 @@ #include #include "libavformat/avformat.h" +#include "libavutil/avassert.h" #include "alsa-audio.h" @@ -60,6 +61,127 @@ static av_cold snd_pcm_format_t codec_id_to_pcm_format(int codec_id) } } +#define REORDER_OUT_50(NAME, TYPE) \ +static void alsa_reorder_ ## NAME ## _out_50(const void *in_v, void *out_v, int n) \ +{ \ + const TYPE *in = in_v; \ + TYPE *out = out_v; \ +\ + while (n-- > 0) { \ + out[0] = in[0]; \ + out[1] = in[1]; \ + out[2] = in[3]; \ + out[3] = in[4]; \ + out[4] = in[2]; \ + in += 5; \ + out += 5; \ + } \ +} + +#define REORDER_OUT_51(NAME, TYPE) \ +static void alsa_reorder_ ## NAME ## _out_51(const void *in_v, void *out_v, int n) \ +{ \ + const TYPE *in = in_v; \ + TYPE *out = out_v; \ +\ + while (n-- > 0) { \ + out[0] = in[0]; \ + out[1] = in[1]; \ + out[2] = in[4]; \ + out[3] = in[5]; \ + out[4] = in[2]; \ + out[5] = in[3]; \ + in += 6; \ + out += 6; \ + } \ +} + +#define REORDER_OUT_71(NAME, TYPE) \ +static void alsa_reorder_ ## NAME ## _out_71(const void *in_v, void *out_v, int n) \ +{ \ + const TYPE *in = in_v; \ + TYPE *out = out_v; \ +\ + while (n-- > 0) { \ + out[0] = in[0]; \ + out[1] = in[1]; \ + out[2] = in[4]; \ + out[3] = in[5]; \ + out[4] = in[2]; \ + out[5] = in[3]; \ + out[6] = in[6]; \ + out[7] = in[7]; \ + in += 8; \ + out += 8; \ + } \ +} + +REORDER_OUT_50(int8, int8_t) +REORDER_OUT_51(int8, int8_t) +REORDER_OUT_71(int8, int8_t) +REORDER_OUT_50(int16, int16_t) +REORDER_OUT_51(int16, int16_t) +REORDER_OUT_71(int16, int16_t) +REORDER_OUT_50(int32, int32_t) +REORDER_OUT_51(int32, int32_t) +REORDER_OUT_71(int32, int32_t) +REORDER_OUT_50(f32, float) +REORDER_OUT_51(f32, float) +REORDER_OUT_71(f32, float) + +#define FORMAT_I8 0 +#define FORMAT_I16 1 +#define FORMAT_I32 2 +#define FORMAT_F32 3 + +#define PICK_REORDER(layout)\ +switch(format) {\ + case FORMAT_I8: s->reorder_func = alsa_reorder_int8_out_ ##layout; break;\ + case FORMAT_I16: s->reorder_func = alsa_reorder_int16_out_ ##layout; break;\ + case FORMAT_I32: s->reorder_func = alsa_reorder_int32_out_ ##layout; break;\ + case FORMAT_F32: s->reorder_func = alsa_reorder_f32_out_ ##layout; break;\ +} + +static av_cold int find_reorder_func(AlsaData *s, int codec_id, int64_t layout, int out) +{ + int format; + + /* reordering input is not currently supported */ + if (!out) + return AVERROR(ENOSYS); + + /* reordering is not needed for QUAD or 2_2 layout */ + if (layout == AV_CH_LAYOUT_QUAD || layout == AV_CH_LAYOUT_2_2) + return 0; + + switch (codec_id) { + case CODEC_ID_PCM_S8: + case CODEC_ID_PCM_U8: + case CODEC_ID_PCM_ALAW: + case CODEC_ID_PCM_MULAW: format = FORMAT_I8; break; + case CODEC_ID_PCM_S16LE: + case CODEC_ID_PCM_S16BE: + case CODEC_ID_PCM_U16LE: + case CODEC_ID_PCM_U16BE: format = FORMAT_I16; break; + case CODEC_ID_PCM_S32LE: + case CODEC_ID_PCM_S32BE: + case CODEC_ID_PCM_U32LE: + case CODEC_ID_PCM_U32BE: format = FORMAT_I32; break; + case CODEC_ID_PCM_F32LE: + case CODEC_ID_PCM_F32BE: format = FORMAT_F32; break; + default: return AVERROR(ENOSYS); + } + + if (layout == AV_CH_LAYOUT_5POINT0_BACK || layout == AV_CH_LAYOUT_5POINT0) + PICK_REORDER(50) + else if (layout == AV_CH_LAYOUT_5POINT1_BACK || layout == AV_CH_LAYOUT_5POINT1) + PICK_REORDER(51) + else if (layout == AV_CH_LAYOUT_7POINT1) + PICK_REORDER(71) + + return s->reorder_func ? 0 : AVERROR(ENOSYS); +} + av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, unsigned int *sample_rate, int channels, enum CodecID *codec_id) @@ -71,6 +193,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, snd_pcm_t *h; snd_pcm_hw_params_t *hw_params; snd_pcm_uframes_t buffer_size, period_size; + int64_t layout = ctx->streams[0]->codec->channel_layout; if (ctx->filename[0] == 0) audio_device = "default"; else audio_device = ctx->filename; @@ -163,6 +286,21 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, snd_pcm_hw_params_free(hw_params); + if (channels > 2 && layout) { + if (find_reorder_func(s, *codec_id, layout, mode == SND_PCM_STREAM_PLAYBACK) < 0) { + char name[128]; + av_get_channel_layout_string(name, sizeof(name), channels, layout); + av_log(ctx, AV_LOG_WARNING, "ALSA channel layout unknown or unimplemented for %s %s.\n", + name, mode == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture"); + } + if (s->reorder_func) { + s->reorder_buf_size = buffer_size; + s->reorder_buf = av_malloc(s->reorder_buf_size * s->frame_size); + if (!s->reorder_buf) + goto fail1; + } + } + s->h = h; return 0; @@ -177,6 +315,7 @@ av_cold int ff_alsa_close(AVFormatContext *s1) { AlsaData *s = s1->priv_data; + av_freep(&s->reorder_buf); snd_pcm_close(s->h); return 0; } @@ -201,3 +340,19 @@ int ff_alsa_xrun_recover(AVFormatContext *s1, int err) } return err; } + +int ff_alsa_extend_reorder_buf(AlsaData *s, int min_size) +{ + int size = s->reorder_buf_size; + void *r; + + av_assert0(size != 0); + while (size < min_size) + size *= 2; + r = av_realloc(s->reorder_buf, size * s->frame_size); + if (!r) + return AVERROR(ENOMEM); + s->reorder_buf = r; + s->reorder_buf_size = size; + return 0; +} diff --git a/libavdevice/alsa-audio-enc.c b/libavdevice/alsa-audio-enc.c index ebe598c86f..f3782c5ab6 100644 --- a/libavdevice/alsa-audio-enc.c +++ b/libavdevice/alsa-audio-enc.c @@ -76,7 +76,15 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt) int size = pkt->size; uint8_t *buf = pkt->data; - while((res = snd_pcm_writei(s->h, buf, size / s->frame_size)) < 0) { + size /= s->frame_size; + if (s->reorder_func) { + if (size > s->reorder_buf_size) + if (ff_alsa_extend_reorder_buf(s, size)) + return AVERROR(ENOMEM); + s->reorder_func(buf, s->reorder_buf, size); + buf = s->reorder_buf; + } + while ((res = snd_pcm_writei(s->h, buf, size)) < 0) { if (res == -EAGAIN) { return AVERROR(EAGAIN); diff --git a/libavdevice/alsa-audio.h b/libavdevice/alsa-audio.h index 32c07426ef..1e0be1cac7 100644 --- a/libavdevice/alsa-audio.h +++ b/libavdevice/alsa-audio.h @@ -47,6 +47,9 @@ typedef struct { int period_size; ///< bytes per sample * channels int sample_rate; ///< sample rate set by user int channels; ///< number of channels set by user + void (*reorder_func)(const void *, void *, int); + void *reorder_buf; + int reorder_buf_size; ///< in frames } AlsaData; /** @@ -86,4 +89,6 @@ int ff_alsa_close(AVFormatContext *s1); */ int ff_alsa_xrun_recover(AVFormatContext *s1, int err); +int ff_alsa_extend_reorder_buf(AlsaData *s, int size); + #endif /* AVDEVICE_ALSA_AUDIO_H */ -- cgit v1.2.3 From da51a7c69cd105498d28a23f1137eef2915a8e6b Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 3 Jun 2011 10:54:10 +0200 Subject: bktr: prefer "framerate" over "fps" for grab_read_header() The variable is used for containing the parsed value of s1->framerate, using a lexically consistent name ease readability/understanding. Signed-off-by: Anton Khirnov --- libavdevice/bktr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libavdevice') diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index 4d3933f4e9..aa3055d946 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -248,7 +248,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) VideoData *s = s1->priv_data; AVStream *st; int width, height; - AVRational fps; + AVRational framerate; int ret = 0; #if FF_API_FORMAT_PARAMETERS @@ -277,7 +277,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) ret = AVERROR(EINVAL); goto out; } - if ((ret = av_parse_video_rate(&fps, s->framerate)) < 0) { + if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) { av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n"); goto out; } @@ -287,7 +287,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) if (ap->height > 0) height = ap->height; if (ap->time_base.num) - fps = (AVRational){ap->time_base.den, ap->time_base.num}; + framerate = (AVRational){ap->time_base.den, ap->time_base.num}; #endif st = av_new_stream(s1, 0); @@ -299,15 +299,15 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) s->width = width; s->height = height; - s->per_frame = ((uint64_t)1000000 * fps.den) / fps.num; + s->per_frame = ((uint64_t)1000000 * framerate.den) / framerate.num; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->pix_fmt = PIX_FMT_YUV420P; st->codec->codec_id = CODEC_ID_RAWVIDEO; st->codec->width = width; st->codec->height = height; - st->codec->time_base.den = fps.num; - st->codec->time_base.num = fps.den; + st->codec->time_base.den = framerate.num; + st->codec->time_base.num = framerate.den; if (bktr_init(s1->filename, width, height, s->standard, -- cgit v1.2.3 From a5351720cc2439219bb348efc81ff3df828df2a3 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 3 Jun 2011 10:31:42 +0200 Subject: fbdev: prefer "framerate_q" over "fps" in device context The variable is used for containing the parsed value of framerate, using a lexically consistent name eases readability/understanding. Signed-off-by: Anton Khirnov --- libavdevice/fbdev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'libavdevice') diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c index afd6b94ed0..68a52693fd 100644 --- a/libavdevice/fbdev.c +++ b/libavdevice/fbdev.c @@ -79,7 +79,7 @@ static enum PixelFormat get_pixfmt_from_fb_varinfo(struct fb_var_screeninfo *var typedef struct { AVClass *class; ///< class for private options int frame_size; ///< size in bytes of a grabbed frame - AVRational fps; ///< framerate + AVRational framerate_q; ///< framerate char *framerate; ///< framerate string set by a private option int64_t time_frame; ///< time for the next frame to output (in 1/1000000 units) @@ -102,14 +102,14 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, enum PixelFormat pix_fmt; int ret, flags = O_RDONLY; - ret = av_parse_video_rate(&fbdev->fps, fbdev->framerate); + ret = av_parse_video_rate(&fbdev->framerate_q, fbdev->framerate); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Couldn't parse framerate.\n"); return ret; } #if FF_API_FORMAT_PARAMETERS if (ap->time_base.num) - fbdev->fps = (AVRational){ap->time_base.den, ap->time_base.num}; + fbdev->framerate_q = (AVRational){ap->time_base.den, ap->time_base.num}; #endif if (!(st = av_new_stream(avctx, 0))) @@ -168,15 +168,15 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, st->codec->width = fbdev->width; st->codec->height = fbdev->heigth; st->codec->pix_fmt = pix_fmt; - st->codec->time_base = (AVRational){fbdev->fps.den, fbdev->fps.num}; + st->codec->time_base = (AVRational){fbdev->framerate_q.den, fbdev->framerate_q.num}; st->codec->bit_rate = - fbdev->width * fbdev->heigth * fbdev->bytes_per_pixel * av_q2d(fbdev->fps) * 8; + fbdev->width * fbdev->heigth * fbdev->bytes_per_pixel * av_q2d(fbdev->framerate_q) * 8; av_log(avctx, AV_LOG_INFO, "w:%d h:%d bpp:%d pixfmt:%s fps:%d/%d bit_rate:%d\n", fbdev->width, fbdev->heigth, fbdev->varinfo.bits_per_pixel, av_pix_fmt_descriptors[pix_fmt].name, - fbdev->fps.num, fbdev->fps.den, + fbdev->framerate_q.num, fbdev->framerate_q.den, st->codec->bit_rate); return 0; @@ -210,7 +210,7 @@ static int fbdev_read_packet(AVFormatContext *avctx, AVPacket *pkt) while (nanosleep(&ts, &ts) < 0 && errno == EINTR); } /* compute the time of the next frame */ - fbdev->time_frame += INT64_C(1000000) / av_q2d(fbdev->fps); + fbdev->time_frame += INT64_C(1000000) / av_q2d(fbdev->framerate_q); if ((ret = av_new_packet(pkt, fbdev->frame_size)) < 0) return ret; -- cgit v1.2.3 From e60068baeb576f34a542c8cad75d5604e9c5a2a9 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 3 Jun 2011 10:39:54 +0200 Subject: v4l2: prefer "framerate_q" over "fps" in v4l2_set_parameters() The variable is used for containing the parsed value of framerate, using a lexically consistent name eases readability/understanding. Signed-off-by: Anton Khirnov --- libavdevice/v4l2.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'libavdevice') diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 2553bca48a..b024c48d2e 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -455,11 +455,11 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) struct v4l2_streamparm streamparm = { 0 }; struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe; int i, ret; - AVRational fps; + AVRational framerate_q; streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (s->framerate && (ret = av_parse_video_rate(&fps, s->framerate)) < 0) { + if (s->framerate && (ret = av_parse_video_rate(&framerate_q, s->framerate)) < 0) { av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n"); return ret; } @@ -467,7 +467,7 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) if (ap->channel > 0) s->channel = ap->channel; if (ap->time_base.num) - fps = (AVRational){ap->time_base.den, ap->time_base.num}; + framerate_q = (AVRational){ap->time_base.den, ap->time_base.num}; #endif /* set tv video input */ @@ -520,23 +520,23 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) } } - if (fps.num && fps.den) { + if (framerate_q.num && framerate_q.den) { av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", - fps.den, fps.num); - tpf->numerator = fps.den; - tpf->denominator = fps.num; + framerate_q.den, framerate_q.num); + tpf->numerator = framerate_q.den; + tpf->denominator = framerate_q.num; if (ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) { av_log(s1, AV_LOG_ERROR, "ioctl set time per frame(%d/%d) failed\n", - fps.den, fps.num); + framerate_q.den, framerate_q.num); return AVERROR(EIO); } - if (fps.num != tpf->denominator || - fps.den != tpf->numerator) { + if (framerate_q.num != tpf->denominator || + framerate_q.den != tpf->numerator) { av_log(s1, AV_LOG_INFO, "The driver changed the time per frame from %d/%d to %d/%d\n", - fps.den, fps.num, + framerate_q.den, framerate_q.num, tpf->numerator, tpf->denominator); } } else { -- cgit v1.2.3 From a4bda405447b13e84b4004ab281ae01abd230e22 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 3 Jun 2011 10:41:47 +0200 Subject: vfwcap: prefer "framerate_q" over "fps" in vfw_read_header() The variable is used for containing the parsed value of framerate, using a lexically consistent name eases readability/understanding. Signed-off-by: Anton Khirnov --- libavdevice/vfwcap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libavdevice') diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c index 95dd4c34b8..80f9d00e9c 100644 --- a/libavdevice/vfwcap.c +++ b/libavdevice/vfwcap.c @@ -249,7 +249,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) DWORD biCompression; WORD biBitCount; int ret; - AVRational fps; + AVRational framerate_q; if (!strcmp(s->filename, "list")) { for (devnum = 0; devnum <= 9; devnum++) { @@ -269,7 +269,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) #if FF_API_FORMAT_PARAMETERS if (ap->time_base.num) - fps = (AVRational){ap->time_base.den, ap->time_base.num}; + framerate_q = (AVRational){ap->time_base.den, ap->time_base.num}; #endif ctx->hwnd = capCreateCaptureWindow(NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0); @@ -369,7 +369,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) cparms.fYield = 1; // Spawn a background thread cparms.dwRequestMicroSecPerFrame = - (fps.den*1000000) / fps.num; + (framerate_q.den*1000000) / framerate_q.num; cparms.fAbortLeftMouse = 0; cparms.fAbortRightMouse = 0; cparms.fCaptureAudio = 0; @@ -381,7 +381,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail_io; codec = st->codec; - codec->time_base = (AVRational){fps.den, fps.num}; + codec->time_base = (AVRational){framerate_q.den, framerate_q.num}; codec->codec_type = AVMEDIA_TYPE_VIDEO; codec->width = bi->bmiHeader.biWidth; codec->height = bi->bmiHeader.biHeight; -- cgit v1.2.3 From 41b68dce4d148b6a227d001b32deb275c01aa550 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 3 Jun 2011 10:50:28 +0200 Subject: lavdev: improve feedback in case of invalid frame rate/size Show the invalid string in the error message. While at it also prefer "Could not" over "Couldn't", plain forms are preferred over contractions (simplify readability, especially for non English-savvy people). Signed-off-by: Anton Khirnov --- libavdevice/bktr.c | 4 ++-- libavdevice/fbdev.c | 2 +- libavdevice/libdc1394.c | 4 ++-- libavdevice/v4l2.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'libavdevice') diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index aa3055d946..f1ae9ea685 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -263,7 +263,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) #endif if ((ret = av_parse_video_size(&width, &height, s->video_size)) < 0) { - av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n"); + av_log(s1, AV_LOG_ERROR, "Could not parse video size '%s'.\n", s->video_size); goto out; } @@ -278,7 +278,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) goto out; } if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) { - av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + av_log(s1, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", s->framerate); goto out; } #if FF_API_FORMAT_PARAMETERS diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c index 68a52693fd..2f3e0ff937 100644 --- a/libavdevice/fbdev.c +++ b/libavdevice/fbdev.c @@ -104,7 +104,7 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, ret = av_parse_video_rate(&fbdev->framerate_q, fbdev->framerate); if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + av_log(avctx, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", fbdev->framerate); return ret; } #if FF_API_FORMAT_PARAMETERS diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c index 622579bc92..bf4e27e51b 100644 --- a/libavdevice/libdc1394.c +++ b/libavdevice/libdc1394.c @@ -134,11 +134,11 @@ static inline int dc1394_read_common(AVFormatContext *c, AVFormatParameters *ap, } if ((ret = av_parse_video_size(&width, &height, dc1394->video_size)) < 0) { - av_log(c, AV_LOG_ERROR, "Couldn't parse video size.\n"); + av_log(c, AV_LOG_ERROR, "Could not parse video size '%s'.\n", dc1394->video_size); goto out; } if ((ret = av_parse_video_rate(&framerate, dc1394->framerate)) < 0) { - av_log(c, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + av_log(c, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", dc1394->framerate); goto out; } #if FF_API_FORMAT_PARAMETERS diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index b024c48d2e..072be48d40 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -460,7 +460,7 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (s->framerate && (ret = av_parse_video_rate(&framerate_q, s->framerate)) < 0) { - av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + av_log(s1, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", s->framerate); return ret; } #if FF_API_FORMAT_PARAMETERS @@ -601,7 +601,7 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap) av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ if (s->video_size && (res = av_parse_video_size(&s->width, &s->height, s->video_size)) < 0) { - av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n"); + av_log(s1, AV_LOG_ERROR, "Could not parse video size '%s'.\n", s->video_size); goto out; } if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == PIX_FMT_NONE) { -- cgit v1.2.3