From 0ba1e1978d4016df42ed481a832e7539ebc48220 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 3 Oct 2011 14:13:17 +0200 Subject: [PATCH 1/3] lavc: use designated initializers for av_codec_context_class --- libavcodec/options.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libavcodec/options.c b/libavcodec/options.c index 0bcdf2a42c..1c5240634b 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -516,7 +516,14 @@ static const AVOption options[]={ #undef D #undef DEFAULT -static const AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options, LIBAVUTIL_VERSION_INT, OFFSET(log_level_offset), .opt_find = opt_find}; +static const AVClass av_codec_context_class = { + .class_name = "AVCodecContext", + .item_name = context_to_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, + .log_level_offset_offset = OFFSET(log_level_offset), + .opt_find = opt_find, +}; void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){ memset(s, 0, sizeof(AVCodecContext)); From a4ea00d021b2bda1b641a2f00c167cadedfe9d4c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 3 Oct 2011 19:14:03 +0200 Subject: [PATCH 2/3] lavc/lavf: use unique private classes. This is needed by the new AVOptions API. --- libavcodec/ac3dec.c | 10 ++++++++-- libavformat/img2.c | 13 +++++++++---- libavformat/movenc.c | 27 +++++++++++++++++---------- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 79360c2253..5046a5c644 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1444,7 +1444,7 @@ static const AVOption options[] = { }; static const AVClass ac3_decoder_class = { - .class_name = "(E-)AC3 decoder", + .class_name = "AC3 decoder", .item_name = av_default_item_name, .option = options, .version = LIBAVUTIL_VERSION_INT, @@ -1466,6 +1466,12 @@ AVCodec ff_ac3_decoder = { }; #if CONFIG_EAC3_DECODER +static const AVClass eac3_decoder_class = { + .class_name = "E-AC3 decoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; AVCodec ff_eac3_decoder = { .name = "eac3", .type = AVMEDIA_TYPE_AUDIO, @@ -1478,6 +1484,6 @@ AVCodec ff_eac3_decoder = { .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .priv_class = &ac3_decoder_class, + .priv_class = &eac3_decoder_class, }; #endif diff --git a/libavformat/img2.c b/libavformat/img2.c index 935d763288..354b38e031 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -458,15 +458,14 @@ static const AVOption options[] = { { NULL }, }; +/* input */ +#if CONFIG_IMAGE2_DEMUXER static const AVClass img2_class = { .class_name = "image2 demuxer", .item_name = av_default_item_name, .option = options, .version = LIBAVUTIL_VERSION_INT, }; - -/* input */ -#if CONFIG_IMAGE2_DEMUXER AVInputFormat ff_image2_demuxer = { .name = "image2", .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), @@ -479,13 +478,19 @@ AVInputFormat ff_image2_demuxer = { }; #endif #if CONFIG_IMAGE2PIPE_DEMUXER +static const AVClass img2pipe_class = { + .class_name = "image2pipe demuxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; AVInputFormat ff_image2pipe_demuxer = { .name = "image2pipe", .long_name = NULL_IF_CONFIG_SMALL("piped image2 sequence"), .priv_data_size = sizeof(VideoData), .read_header = read_header, .read_packet = read_packet, - .priv_class = &img2_class, + .priv_class = &img2pipe_class, }; #endif diff --git a/libavformat/movenc.c b/libavformat/movenc.c index b79bbe83c6..9e1a4ceaf2 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -48,11 +48,12 @@ static const AVOption options[] = { { NULL }, }; -static const AVClass mov_muxer_class = { - .class_name = "MOV/3GP/MP4/3G2 muxer", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, +#define MOV_CLASS(flavor)\ +static const AVClass flavor ## _muxer_class = {\ + .class_name = #flavor " muxer",\ + .item_name = av_default_item_name,\ + .option = options,\ + .version = LIBAVUTIL_VERSION_INT,\ }; //FIXME support 64 bit variant with wide placeholders @@ -2338,6 +2339,7 @@ static int mov_write_trailer(AVFormatContext *s) } #if CONFIG_MOV_MUXER +MOV_CLASS(mov) AVOutputFormat ff_mov_muxer = { .name = "mov", .long_name = NULL_IF_CONFIG_SMALL("MOV format"), @@ -2358,6 +2360,7 @@ AVOutputFormat ff_mov_muxer = { }; #endif #if CONFIG_TGP_MUXER +MOV_CLASS(tgp) AVOutputFormat ff_tgp_muxer = { .name = "3gp", .long_name = NULL_IF_CONFIG_SMALL("3GP format"), @@ -2370,10 +2373,11 @@ AVOutputFormat ff_tgp_muxer = { .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0}, - .priv_class = &mov_muxer_class, + .priv_class = &tgp_muxer_class, }; #endif #if CONFIG_MP4_MUXER +MOV_CLASS(mp4) AVOutputFormat ff_mp4_muxer = { .name = "mp4", .long_name = NULL_IF_CONFIG_SMALL("MP4 format"), @@ -2391,10 +2395,11 @@ AVOutputFormat ff_mp4_muxer = { .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0}, - .priv_class = &mov_muxer_class, + .priv_class = &mp4_muxer_class, }; #endif #if CONFIG_PSP_MUXER +MOV_CLASS(psp) AVOutputFormat ff_psp_muxer = { .name = "psp", .long_name = NULL_IF_CONFIG_SMALL("PSP MP4 format"), @@ -2411,10 +2416,11 @@ AVOutputFormat ff_psp_muxer = { .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0}, - .priv_class = &mov_muxer_class, + .priv_class = &psp_muxer_class, }; #endif #if CONFIG_TG2_MUXER +MOV_CLASS(tg2) AVOutputFormat ff_tg2_muxer = { .name = "3g2", .long_name = NULL_IF_CONFIG_SMALL("3GP2 format"), @@ -2427,10 +2433,11 @@ AVOutputFormat ff_tg2_muxer = { .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0}, - .priv_class = &mov_muxer_class, + .priv_class = &tg2_muxer_class, }; #endif #if CONFIG_IPOD_MUXER +MOV_CLASS(ipod) AVOutputFormat ff_ipod_muxer = { .name = "ipod", .long_name = NULL_IF_CONFIG_SMALL("iPod H.264 MP4 format"), @@ -2444,6 +2451,6 @@ AVOutputFormat ff_ipod_muxer = { .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){codec_ipod_tags, 0}, - .priv_class = &mov_muxer_class, + .priv_class = &ipod_muxer_class, }; #endif From e83c2ddebf8ee90086d8e34de9c8ba245f548f89 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 5 Oct 2011 11:12:01 +0200 Subject: [PATCH 3/3] Fix 'heigth' vs. 'height' typos. --- doc/filters.texi | 14 +++++++------- libavcodec/dnxhddec.c | 2 +- libavdevice/fbdev.c | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 13a66d4e0e..46274acd54 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -204,13 +204,13 @@ the computed values for @var{x} and @var{y}. They are evaluated for each new frame. @item in_w, in_h -the input width and heigth +the input width and height @item iw, ih same as @var{in_w} and @var{in_h} @item out_w, out_h -the output (cropped) width and heigth +the output (cropped) width and height @item ow, oh same as @var{out_w} and @var{out_h} @@ -895,13 +895,13 @@ the corresponding mathematical approximated values for e (euler number), pi (greek PI), phi (golden ratio) @item in_w, in_h -the input video width and heigth +the input video width and height @item iw, ih same as @var{in_w} and @var{in_h} @item out_w, out_h -the output width and heigth, that is the size of the padded area as +the output width and height, that is the size of the padded area as specified by the @var{width} and @var{height} expressions @item ow, oh @@ -1002,13 +1002,13 @@ the corresponding mathematical approximated values for e (euler number), pi (greek PI), phi (golden ratio) @item in_w, in_h -the input width and heigth +the input width and height @item iw, ih same as @var{in_w} and @var{in_h} @item out_w, out_h -the output (cropped) width and heigth +the output (cropped) width and height @item ow, oh same as @var{out_w} and @var{out_h} @@ -1626,7 +1626,7 @@ alpha specifier. The default value is "black". @item frame_size Specify the size of the sourced video, it may be a string of the form -@var{width}x@var{heigth}, or the name of a size abbreviation. The +@var{width}x@var{height}, or the name of a size abbreviation. The default value is "320x240". @item frame_rate diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 7198a2f796..48932783c3 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -115,7 +115,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si ctx->height = AV_RB16(buf + 0x18); ctx->width = AV_RB16(buf + 0x1a); - av_dlog(ctx->avctx, "width %d, heigth %d\n", ctx->width, ctx->height); + av_dlog(ctx->avctx, "width %d, height %d\n", ctx->width, ctx->height); if (buf[0x21] & 0x40) { ctx->avctx->pix_fmt = PIX_FMT_YUV422P10; diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c index 57c257f7b6..58a3290947 100644 --- a/libavdevice/fbdev.c +++ b/libavdevice/fbdev.c @@ -84,7 +84,7 @@ typedef struct { int64_t time_frame; ///< time for the next frame to output (in 1/1000000 units) int fd; ///< framebuffer device file descriptor - int width, heigth; ///< assumed frame resolution + int width, height; ///< assumed frame resolution int frame_linesize; ///< linesize of the output frame, it is assumed to be constant int bytes_per_pixel; @@ -147,10 +147,10 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, } fbdev->width = fbdev->varinfo.xres; - fbdev->heigth = fbdev->varinfo.yres; + fbdev->height = fbdev->varinfo.yres; fbdev->bytes_per_pixel = (fbdev->varinfo.bits_per_pixel + 7) >> 3; fbdev->frame_linesize = fbdev->width * fbdev->bytes_per_pixel; - fbdev->frame_size = fbdev->frame_linesize * fbdev->heigth; + fbdev->frame_size = fbdev->frame_linesize * fbdev->height; fbdev->time_frame = AV_NOPTS_VALUE; fbdev->data = mmap(NULL, fbdev->fixinfo.smem_len, PROT_READ, MAP_SHARED, fbdev->fd, 0); if (fbdev->data == MAP_FAILED) { @@ -162,15 +162,15 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO; st->codec->width = fbdev->width; - st->codec->height = fbdev->heigth; + st->codec->height = fbdev->height; st->codec->pix_fmt = pix_fmt; 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->framerate_q) * 8; + fbdev->width * fbdev->height * 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, + fbdev->width, fbdev->height, fbdev->varinfo.bits_per_pixel, av_pix_fmt_descriptors[pix_fmt].name, fbdev->framerate_q.num, fbdev->framerate_q.den, st->codec->bit_rate); @@ -224,7 +224,7 @@ static int fbdev_read_packet(AVFormatContext *avctx, AVPacket *pkt) pout = pkt->data; // TODO it'd be nice if the lines were aligned - for (i = 0; i < fbdev->heigth; i++) { + for (i = 0; i < fbdev->height; i++) { memcpy(pout, pin, fbdev->frame_linesize); pin += fbdev->fixinfo.line_length; pout += fbdev->frame_linesize;