Unified · Split
| @@ -7,7 +7,7 @@ version 5.1: · 6 unmodified lines | |||
| 7 | - pcm-bluray encoder | 7 | - pcm-bluray encoder |
| 8 | - DFPWM audio encoder/decoder and raw muxer/demuxer | 8 | - DFPWM audio encoder/decoder and raw muxer/demuxer |
| 9 | - SITI filter | 9 | - SITI filter |
| 10 | - Vizrt Binary Image decoder | 10 | - Vizrt Binary Image encoder/decoder |
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | version 5.0: | 13 | version 5.0: |
| @@ -2960,6 +2960,7 @@ utvideo_decoder_select="bswapdsp llviddsp" · 2959 unmodified lines | |||
| 2960 | utvideo_encoder_select="bswapdsp huffman llvidencdsp" | 2960 | utvideo_encoder_select="bswapdsp huffman llvidencdsp" |
| 2961 | vble_decoder_select="llviddsp" | 2961 | vble_decoder_select="llviddsp" |
| 2962 | vbn_decoder_select="texturedsp" | 2962 | vbn_decoder_select="texturedsp" |
| 2963 | vbn_encoder_select="texturedspenc" | ||
| 2963 | vc1_decoder_select="blockdsp h263_decoder h264qpel intrax8 mpegvideodec vc1dsp" | 2964 | vc1_decoder_select="blockdsp h263_decoder h264qpel intrax8 mpegvideodec vc1dsp" |
| 2964 | vc1image_decoder_select="vc1_decoder" | 2965 | vc1image_decoder_select="vc1_decoder" |
| 2965 | vorbis_decoder_select="mdct" | 2966 | vorbis_decoder_select="mdct" |
| @@ -3773,6 +3773,22 @@ required to produce a stream usable with all decoders. · 3772 unmodified lines | |||
| 3773 | 3773 | ||
| 3774 | @end table | 3774 | @end table |
| 3775 | 3775 | ||
| 3776 | @section vbn | ||
| 3777 | |||
| 3778 | Vizrt Binary Image encoder. | ||
| 3779 | |||
| 3780 | This format is used by the broadcast vendor Vizrt for quick texture streaming. | ||
| 3781 | Advanced features of the format such as LZW compression of texture data or | ||
| 3782 | generation of mipmaps are not supported. | ||
| 3783 | |||
| 3784 | @subsection Options | ||
| 3785 | |||
| 3786 | @table @option | ||
| 3787 | @item format @var{string} | ||
| 3788 | Sets the texture compression used by the VBN file. Can be @var{dxt1}, | ||
| 3789 | @var{dxt5} or @var{raw}. Default is @var{dxt5}. | ||
| 3790 | @end table | ||
| 3791 | |||
| 3776 | @section vc2 | 3792 | @section vc2 |
| 3777 | 3793 | ||
| 3778 | SMPTE VC-2 (previously BBC Dirac Pro). This codec was primarily aimed at | 3794 | SMPTE VC-2 (previously BBC Dirac Pro). This codec was primarily aimed at |
| @@ -786,6 +786,8 @@ following image formats are supported: · 785 unmodified lines | |||
| 786 | @tab YUV, JPEG and some extension is not supported yet. | 786 | @tab YUV, JPEG and some extension is not supported yet. |
| 787 | @item Truevision Targa @tab X @tab X | 787 | @item Truevision Targa @tab X @tab X |
| 788 | @tab Targa (.TGA) image format | 788 | @tab Targa (.TGA) image format |
| 789 | @item VBN @tab X @tab X | ||
| 790 | @tab Vizrt Binary Image format | ||
| 789 | @item WebP @tab E @tab X | 791 | @item WebP @tab E @tab X |
| 790 | @tab WebP image format, encoding supported through external library libwebp | 792 | @tab WebP image format, encoding supported through external library libwebp |
| 791 | @item XBM @tab X @tab X | 793 | @item XBM @tab X @tab X |
| @@ -709,6 +709,7 @@ OBJS-$(CONFIG_V410_DECODER) += v410dec.o · 708 unmodified lines | |||
| 709 | OBJS-$(CONFIG_V410_ENCODER) += v410enc.o | 709 | OBJS-$(CONFIG_V410_ENCODER) += v410enc.o |
| 710 | OBJS-$(CONFIG_VB_DECODER) += vb.o | 710 | OBJS-$(CONFIG_VB_DECODER) += vb.o |
| 711 | OBJS-$(CONFIG_VBN_DECODER) += vbndec.o | 711 | OBJS-$(CONFIG_VBN_DECODER) += vbndec.o |
| 712 | OBJS-$(CONFIG_VBN_ENCODER) += vbnenc.o | ||
| 712 | OBJS-$(CONFIG_VBLE_DECODER) += vble.o | 713 | OBJS-$(CONFIG_VBLE_DECODER) += vble.o |
| 713 | OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o vc1_block.o vc1_loopfilter.o \ | 714 | OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o vc1_block.o vc1_loopfilter.o \ |
| 714 | vc1_mc.o vc1_pred.o vc1.o vc1data.o \ | 715 | vc1_mc.o vc1_pred.o vc1.o vc1data.o \ |
| @@ -347,6 +347,7 @@ extern const FFCodec ff_v408_decoder; · 346 unmodified lines | |||
| 347 | extern const FFCodec ff_v410_encoder; | 347 | extern const FFCodec ff_v410_encoder; |
| 348 | extern const FFCodec ff_v410_decoder; | 348 | extern const FFCodec ff_v410_decoder; |
| 349 | extern const FFCodec ff_vb_decoder; | 349 | extern const FFCodec ff_vb_decoder; |
| 350 | extern const FFCodec ff_vbn_encoder; | ||
| 350 | extern const FFCodec ff_vbn_decoder; | 351 | extern const FFCodec ff_vbn_decoder; |
| 351 | extern const FFCodec ff_vble_decoder; | 352 | extern const FFCodec ff_vble_decoder; |
| 352 | extern const FFCodec ff_vc1_decoder; | 353 | extern const FFCodec ff_vc1_decoder; |
| @@ -0,0 +1,173 @@ | |||
| 1 | /* | ||
| 2 | * Vizrt Binary Image encoder | ||
| 3 | * | ||
| 4 | * This file is part of FFmpeg. | ||
| 5 | * | ||
| 6 | * FFmpeg is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU Lesser General Public | ||
| 8 | * License as published by the Free Software Foundation; either | ||
| 9 | * version 2.1 of the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * Lesser General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU Lesser General Public | ||
| 17 | * License along with FFmpeg; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @file | ||
| 23 | * Vizrt Binary Image encoder | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include "avcodec.h" | ||
| 27 | #include "bytestream.h" | ||
| 28 | #include "codec_internal.h" | ||
| 29 | #include "encode.h" | ||
| 30 | #include "texturedsp.h" | ||
| 31 | #include "vbn.h" | ||
| 32 | |||
| 33 | #include "libavutil/imgutils.h" | ||
| 34 | #include "libavutil/frame.h" | ||
| 35 | #include "libavutil/opt.h" | ||
| 36 | |||
| 37 | typedef struct VBNContext { | ||
| 38 | AVClass *class; | ||
| 39 | TextureDSPContext dxtc; | ||
| 40 | PutByteContext pb; | ||
| 41 | int format; | ||
| 42 | TextureDSPThreadContext enc; | ||
| 43 | } VBNContext; | ||
| 44 | |||
| 45 | static int vbn_encode(AVCodecContext *avctx, AVPacket *pkt, | ||
| 46 | const AVFrame *frame, int *got_packet) | ||
| 47 | { | ||
| 48 | VBNContext *ctx = avctx->priv_data; | ||
| 49 | PutByteContext *pb = &ctx->pb; | ||
| 50 | int ret; | ||
| 51 | ptrdiff_t linesize; | ||
| 52 | int64_t pkt_size; | ||
| 53 | |||
| 54 | ret = av_image_check_size2(frame->width, frame->height, INT_MAX, frame->format, 0, avctx); | ||
| 55 | if (ret < 0) | ||
| 56 | return ret; | ||
| 57 | |||
| 58 | if (ctx->format == VBN_FORMAT_DXT1 || ctx->format == VBN_FORMAT_DXT5) { | ||
| 59 | if (frame->width % TEXTURE_BLOCK_W || frame->height % TEXTURE_BLOCK_H) { | ||
| 60 | av_log(avctx, AV_LOG_ERROR, "Video size %dx%d is not multiple of 4\n", frame->width, frame->height); | ||
| 61 | return AVERROR(EINVAL); | ||
| 62 | } | ||
| 63 | if (frame->format != AV_PIX_FMT_RGBA) { | ||
| 64 | av_log(avctx, AV_LOG_ERROR, "DXT formats only support RGBA pixel format\n"); | ||
| 65 | return AVERROR(EINVAL); | ||
| 66 | } | ||
| 67 | ctx->enc.raw_ratio = 16; | ||
| 68 | ctx->enc.slice_count = av_clip(avctx->thread_count, 1, avctx->height / TEXTURE_BLOCK_H); | ||
| 69 | } | ||
| 70 | |||
| 71 | switch (ctx->format) { | ||
| 72 | case VBN_FORMAT_DXT1: | ||
| 73 | linesize = frame->width / 2; | ||
| 74 | ctx->enc.tex_funct = ctx->dxtc.dxt1_block; | ||
| 75 | ctx->enc.tex_ratio = 8; | ||
| 76 | break; | ||
| 77 | case VBN_FORMAT_DXT5: | ||
| 78 | linesize = frame->width; | ||
| 79 | ctx->enc.tex_funct = ctx->dxtc.dxt5_block; | ||
| 80 | ctx->enc.tex_ratio = 16; | ||
| 81 | break; | ||
| 82 | case VBN_FORMAT_RAW: | ||
| 83 | linesize = av_image_get_linesize(frame->format, frame->width, 0); | ||
| 84 | if (linesize < 0) | ||
| 85 | return linesize; | ||
| 86 | break; | ||
| 87 | default: | ||
| 88 | av_log(avctx, AV_LOG_ERROR, "Invalid format %02X\n", ctx->format); | ||
| 89 | return AVERROR(EINVAL); | ||
| 90 | } | ||
| 91 | |||
| 92 | pkt_size = VBN_HEADER_SIZE + linesize * frame->height; | ||
| 93 | if (pkt_size > INT_MAX) | ||
| 94 | return AVERROR(EINVAL); | ||
| 95 | |||
| 96 | if ((ret = ff_get_encode_buffer(avctx, pkt, pkt_size, 0)) < 0) | ||
| 97 | return ret; | ||
| 98 | |||
| 99 | memset(pkt->data, 0, VBN_HEADER_SIZE); | ||
| 100 | bytestream2_init_writer(pb, pkt->data, pkt_size); | ||
| 101 | bytestream2_put_le32(pb, VBN_MAGIC); | ||
| 102 | bytestream2_put_le32(pb, VBN_MAJOR); | ||
| 103 | bytestream2_put_le32(pb, VBN_MINOR); | ||
| 104 | bytestream2_put_le32(pb, frame->width); | ||
| 105 | bytestream2_put_le32(pb, frame->height); | ||
| 106 | bytestream2_put_le32(pb, frame->format == AV_PIX_FMT_RGBA ? 4 : 3); | ||
| 107 | bytestream2_put_le32(pb, ctx->format); | ||
| 108 | bytestream2_put_le32(pb, frame->format == AV_PIX_FMT_RGBA ? VBN_PIX_RGBA : VBN_PIX_RGB); | ||
| 109 | bytestream2_put_le32(pb, 0); // mipmaps | ||
| 110 | bytestream2_put_le32(pb, pkt_size - VBN_HEADER_SIZE); | ||
| 111 | bytestream2_seek_p(pb, 64, SEEK_SET); | ||
| 112 | bytestream2_put_le32(pb, pkt_size - VBN_HEADER_SIZE); | ||
| 113 | |||
| 114 | if (ctx->format == VBN_FORMAT_DXT1 || ctx->format == VBN_FORMAT_DXT5) { | ||
| 115 | ctx->enc.frame_data.in = (frame->height - 1) * frame->linesize[0] + frame->data[0]; | ||
| 116 | ctx->enc.stride = -frame->linesize[0]; | ||
| 117 | ctx->enc.tex_data.out = pkt->data + VBN_HEADER_SIZE; | ||
| 118 | avctx->execute2(avctx, ff_texturedsp_compress_thread, &ctx->enc, NULL, ctx->enc.slice_count); | ||
| 119 | } else { | ||
| 120 | uint8_t *flipped = frame->data[0] + frame->linesize[0] * (frame->height - 1); | ||
| 121 | av_image_copy_plane(pkt->data + VBN_HEADER_SIZE, linesize, flipped, -frame->linesize[0], linesize, frame->height); | ||
| 122 | } | ||
| 123 | |||
| 124 | *got_packet = 1; | ||
| 125 | return 0; | ||
| 126 | } | ||
| 127 | |||
| 128 | static av_cold int vbn_init(AVCodecContext *avctx) | ||
| 129 | { | ||
| 130 | VBNContext *ctx = avctx->priv_data; | ||
| 131 | ff_texturedspenc_init(&ctx->dxtc); | ||
| 132 | return 0; | ||
| 133 | } | ||
| 134 | |||
| 135 | static av_cold int vbn_close(AVCodecContext *avctx) | ||
| 136 | { | ||
| 137 | return 0; | ||
| 138 | } | ||
| 139 | |||
| 140 | #define OFFSET(x) offsetof(VBNContext, x) | ||
| 141 | #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM | ||
| 142 | static const AVOption options[] = { | ||
| 143 | { "format", "Texture format", OFFSET(format), AV_OPT_TYPE_INT, { .i64 = VBN_FORMAT_DXT5 }, VBN_FORMAT_RAW, VBN_FORMAT_DXT5, FLAGS, "format" }, | ||
| 144 | { "raw", "RAW texture", 0, AV_OPT_TYPE_CONST, { .i64 = VBN_FORMAT_RAW }, 0, 0, FLAGS, "format" }, | ||
| 145 | { "dxt1", "DXT1 texture", 0, AV_OPT_TYPE_CONST, { .i64 = VBN_FORMAT_DXT1 }, 0, 0, FLAGS, "format" }, | ||
| 146 | { "dxt5", "DXT5 texture", 0, AV_OPT_TYPE_CONST, { .i64 = VBN_FORMAT_DXT5 }, 0, 0, FLAGS, "format" }, | ||
| 147 | { NULL }, | ||
| 148 | }; | ||
| 149 | |||
| 150 | static const AVClass vbnenc_class = { | ||
| 151 | .class_name = "VBN encoder", | ||
| 152 | .item_name = av_default_item_name, | ||
| 153 | .option = options, | ||
| 154 | .version = LIBAVUTIL_VERSION_INT, | ||
| 155 | }; | ||
| 156 | |||
| 157 | const FFCodec ff_vbn_encoder = { | ||
| 158 | .p.name = "vbn", | ||
| 159 | .p.long_name = NULL_IF_CONFIG_SMALL("Vizrt Binary Image"), | ||
| 160 | .p.type = AVMEDIA_TYPE_VIDEO, | ||
| 161 | .p.id = AV_CODEC_ID_VBN, | ||
| 162 | .p.capabilities = AV_CODEC_CAP_SLICE_THREADS, | ||
| 163 | .p.priv_class = &vbnenc_class, | ||
| 164 | .init = vbn_init, | ||
| 165 | FF_CODEC_ENCODE_CB(vbn_encode), | ||
| 166 | .close = vbn_close, | ||
| 167 | .priv_data_size = sizeof(VBNContext), | ||
| 168 | .p.pix_fmts = (const enum AVPixelFormat[]) { | ||
| 169 | AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE, | ||
| 170 | }, | ||
| 171 | .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | | ||
| 172 | FF_CODEC_CAP_INIT_CLEANUP, | ||
| 173 | }; | ||
| @@ -29,8 +29,8 @@ · 28 unmodified lines | |||
| 29 | 29 | ||
| 30 | #include "version_major.h" | 30 | #include "version_major.h" |
| 31 | 31 | ||
| 32 | #define LIBAVCODEC_VERSION_MINOR 25 | 32 | #define LIBAVCODEC_VERSION_MINOR 26 |
| 33 | #define LIBAVCODEC_VERSION_MICRO 101 | 33 | #define LIBAVCODEC_VERSION_MICRO 100 |
| 34 | 34 | ||
| 35 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ | 35 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| 36 | LIBAVCODEC_VERSION_MINOR, \ | 36 | LIBAVCODEC_VERSION_MINOR, \ |
| @@ -265,7 +265,7 @@ const AVOutputFormat ff_image2_muxer = { · 264 unmodified lines | |||
| 265 | .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), | 265 | .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), |
| 266 | .extensions = "bmp,dpx,exr,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,png," | 266 | .extensions = "bmp,dpx,exr,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,png," |
| 267 | "ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,im24," | 267 | "ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,im24," |
| 268 | "sunras,xbm,xface,pix,y", | 268 | "sunras,vbn,xbm,xface,pix,y", |
| 269 | .priv_data_size = sizeof(VideoMuxData), | 269 | .priv_data_size = sizeof(VideoMuxData), |
| 270 | .video_codec = AV_CODEC_ID_MJPEG, | 270 | .video_codec = AV_CODEC_ID_MJPEG, |
| 271 | .write_header = write_header, | 271 | .write_header = write_header, |
| @@ -31,8 +31,8 @@ · 30 unmodified lines | |||
| 31 | 31 | ||
| 32 | #include "version_major.h" | 32 | #include "version_major.h" |
| 33 | 33 | ||
| 34 | #define LIBAVFORMAT_VERSION_MINOR 20 | 34 | #define LIBAVFORMAT_VERSION_MINOR 21 |
| 35 | #define LIBAVFORMAT_VERSION_MICRO 101 | 35 | #define LIBAVFORMAT_VERSION_MICRO 100 |
| 36 | 36 | ||
| 37 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ | 37 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
| 38 | LIBAVFORMAT_VERSION_MINOR, \ | 38 | LIBAVFORMAT_VERSION_MINOR, \ |