Add a wrapper for libutvideo's decoder. This supports decoding the following FOURCCs: ULY0 - 4:2:0 YCbCr ULY2 - 4:2:2 YCbCr ULRG - RGB ULRA - RGBA Also, bump version.
Unified · Split
| @@ -185,6 +185,7 @@ External library support: · 184 unmodified lines | |||
| 185 | --enable-libspeex enable Speex encoding and decoding via libspeex [no] | 185 | --enable-libspeex enable Speex encoding and decoding via libspeex [no] |
| 186 | --enable-libstagefright-h264 enable H.264 decoding via libstagefright [no] | 186 | --enable-libstagefright-h264 enable H.264 decoding via libstagefright [no] |
| 187 | --enable-libtheora enable Theora encoding via libtheora [no] | 187 | --enable-libtheora enable Theora encoding via libtheora [no] |
| 188 | --enable-libutvideo enable Ut Video decoding via libutvideo [no] | ||
| 188 | --enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no] | 189 | --enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no] |
| 189 | --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no] | 190 | --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no] |
| 190 | --enable-libvorbis enable Vorbis encoding via libvorbis, | 191 | --enable-libvorbis enable Vorbis encoding via libvorbis, |
| @@ -1015,6 +1016,7 @@ CONFIG_LIST=" · 824 unmodified lines | |||
| 1015 | libspeex | 1016 | libspeex |
| 1016 | libstagefright_h264 | 1017 | libstagefright_h264 |
| 1017 | libtheora | 1018 | libtheora |
| 1019 | libutvideo | ||
| 1018 | libvo_aacenc | 1020 | libvo_aacenc |
| 1019 | libvo_amrwbenc | 1021 | libvo_amrwbenc |
| 1020 | libvorbis | 1022 | libvorbis |
| @@ -1513,6 +1515,7 @@ libvpx_encoder_deps="libvpx" · 492 unmodified lines | |||
| 1513 | libx264_encoder_deps="libx264" | 1515 | libx264_encoder_deps="libx264" |
| 1514 | libxavs_encoder_deps="libxavs" | 1516 | libxavs_encoder_deps="libxavs" |
| 1515 | libxvid_encoder_deps="libxvid" | 1517 | libxvid_encoder_deps="libxvid" |
| 1518 | libutvideo_decoder_deps="libutvideo gpl" | ||
| 1516 | 1519 | ||
| 1517 | # demuxers / muxers | 1520 | # demuxers / muxers |
| 1518 | ac3_demuxer_select="ac3_parser" | 1521 | ac3_demuxer_select="ac3_parser" |
| @@ -3035,6 +3038,7 @@ enabled libstagefright_h264 && require_cpp libstagefright_h264 "binder/ProcessS · 1516 unmodified lines | |||
| 3035 | media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h | 3038 | media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h |
| 3036 | media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder | 3039 | media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder |
| 3037 | enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg | 3040 | enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg |
| 3041 | enabled libutvideo && require_cpp utvideo "stdint.h stdlib.h utvideo/utvideo.h utvideo/Codec.h" 'CCodec*' -lutvideo -lstdc++ | ||
| 3038 | enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc | 3042 | enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc |
| 3039 | enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc | 3043 | enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc |
| 3040 | enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg | 3044 | enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg |
| @@ -3361,6 +3365,7 @@ echo "libschroedinger enabled ${libschroedinger-no}" · 320 unmodified lines | |||
| 3361 | echo "libspeex enabled ${libspeex-no}" | 3365 | echo "libspeex enabled ${libspeex-no}" |
| 3362 | echo "libstagefright-h264 enabled ${libstagefright_h264-no}" | 3366 | echo "libstagefright-h264 enabled ${libstagefright_h264-no}" |
| 3363 | echo "libtheora enabled ${libtheora-no}" | 3367 | echo "libtheora enabled ${libtheora-no}" |
| 3368 | echo "libutvideo enabled ${libutvideo-no}" | ||
| 3364 | echo "libvo-aacenc support ${libvo_aacenc-no}" | 3369 | echo "libvo-aacenc support ${libvo_aacenc-no}" |
| 3365 | echo "libvo-amrwbenc support ${libvo_amrwbenc-no}" | 3370 | echo "libvo-amrwbenc support ${libvo_amrwbenc-no}" |
| 3366 | echo "libvorbis enabled ${libvorbis-no}" | 3371 | echo "libvorbis enabled ${libvorbis-no}" |
| @@ -606,6 +606,7 @@ OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o · 605 unmodified lines | |||
| 606 | OBJS-$(CONFIG_LIBSPEEX_ENCODER) += libspeexenc.o | 606 | OBJS-$(CONFIG_LIBSPEEX_ENCODER) += libspeexenc.o |
| 607 | OBJS-$(CONFIG_LIBSTAGEFRIGHT_H264_DECODER)+= libstagefright.o | 607 | OBJS-$(CONFIG_LIBSTAGEFRIGHT_H264_DECODER)+= libstagefright.o |
| 608 | OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o | 608 | OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o |
| 609 | OBJS-$(CONFIG_LIBUTVIDEO_DECODER) += libutvideo.o | ||
| 609 | OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) += libvo-aacenc.o mpeg4audio.o | 610 | OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) += libvo-aacenc.o mpeg4audio.o |
| 610 | OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o | 611 | OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o |
| 611 | OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o vorbis_data.o | 612 | OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o vorbis_data.o |
| @@ -389,6 +389,7 @@ void avcodec_register_all(void) · 388 unmodified lines | |||
| 389 | REGISTER_ENCDEC (LIBSPEEX, libspeex); | 389 | REGISTER_ENCDEC (LIBSPEEX, libspeex); |
| 390 | REGISTER_DECODER (LIBSTAGEFRIGHT_H264, libstagefright_h264); | 390 | REGISTER_DECODER (LIBSTAGEFRIGHT_H264, libstagefright_h264); |
| 391 | REGISTER_ENCODER (LIBTHEORA, libtheora); | 391 | REGISTER_ENCODER (LIBTHEORA, libtheora); |
| 392 | REGISTER_DECODER (LIBUTVIDEO, libutvideo); | ||
| 392 | REGISTER_ENCODER (LIBVO_AACENC, libvo_aacenc); | 393 | REGISTER_ENCODER (LIBVO_AACENC, libvo_aacenc); |
| 393 | REGISTER_ENCODER (LIBVO_AMRWBENC, libvo_amrwbenc); | 394 | REGISTER_ENCODER (LIBVO_AMRWBENC, libvo_amrwbenc); |
| 394 | REGISTER_ENCODER (LIBVORBIS, libvorbis); | 395 | REGISTER_ENCODER (LIBVORBIS, libvorbis); |
| @@ -212,6 +212,7 @@ enum CodecID { · 211 unmodified lines | |||
| 212 | CODEC_ID_VC1IMAGE, | 212 | CODEC_ID_VC1IMAGE, |
| 213 | CODEC_ID_8SVX_RAW, | 213 | CODEC_ID_8SVX_RAW, |
| 214 | CODEC_ID_G2M, | 214 | CODEC_ID_G2M, |
| 215 | CODEC_ID_UTVIDEO = 0x800, | ||
| 215 | 216 | ||
| 216 | /* various PCM "codecs" */ | 217 | /* various PCM "codecs" */ |
| 217 | CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs | 218 | CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs |
| @@ -0,0 +1,230 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2011 Derek Buitenhuis | ||
| 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 General Public | ||
| 8 | * License as published by the Free Software Foundation; | ||
| 9 | * version 2 of the License. | ||
| 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 | * General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU 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 | * Known FOURCCs: | ||
| 24 | * 'ULY0' (YCbCr 4:2:0), 'ULY2' (YCbCr 4:2:2), 'ULRG' (RGB), 'ULRA' (RGBA) | ||
| 25 | */ | ||
| 26 | |||
| 27 | extern "C" { | ||
| 28 | #include "avcodec.h" | ||
| 29 | } | ||
| 30 | |||
| 31 | #include <stdlib.h> | ||
| 32 | #include <utvideo/utvideo.h> | ||
| 33 | #include <utvideo/Codec.h> | ||
| 34 | |||
| 35 | #include "get_bits.h" | ||
| 36 | |||
| 37 | typedef struct { | ||
| 38 | uint32_t version; | ||
| 39 | uint32_t original_format; | ||
| 40 | uint32_t stripes; | ||
| 41 | uint32_t flags; | ||
| 42 | } UtVideoExtra; | ||
| 43 | |||
| 44 | typedef struct { | ||
| 45 | CCodec *codec; | ||
| 46 | unsigned int buf_size; | ||
| 47 | uint8_t *output; | ||
| 48 | } UtVideoContext; | ||
| 49 | |||
| 50 | static av_cold int utvideo_decode_init(AVCodecContext *avctx) | ||
| 51 | { | ||
| 52 | UtVideoContext *utv = (UtVideoContext *)avctx->priv_data; | ||
| 53 | UtVideoExtra info; | ||
| 54 | int defined_fourcc = 0; | ||
| 55 | |||
| 56 | if(avctx->extradata_size != 4*4) | ||
| 57 | { | ||
| 58 | av_log(avctx, AV_LOG_ERROR, "Extradata size mismatch.\n"); | ||
| 59 | return -1; | ||
| 60 | } | ||
| 61 | |||
| 62 | /* Read extradata */ | ||
| 63 | info.version = AV_RL32(avctx->extradata); | ||
| 64 | info.original_format = AV_RL32(avctx->extradata + 4); | ||
| 65 | info.stripes = AV_RL32(avctx->extradata + 8); | ||
| 66 | info.flags = AV_RL32(avctx->extradata + 12); | ||
| 67 | |||
| 68 | /* Try to output the original format */ | ||
| 69 | switch(UNFCC(info.original_format)) | ||
| 70 | { | ||
| 71 | case UTVF_YV12: | ||
| 72 | avctx->pix_fmt = PIX_FMT_YUV420P; | ||
| 73 | break; | ||
| 74 | case UTVF_YUY2: | ||
| 75 | case UTVF_YUYV: | ||
| 76 | case UTVF_YUNV: | ||
| 77 | avctx->pix_fmt = PIX_FMT_YUYV422; | ||
| 78 | break; | ||
| 79 | case UTVF_UYVY: | ||
| 80 | case UTVF_UYNV: | ||
| 81 | avctx->pix_fmt = PIX_FMT_UYVY422; | ||
| 82 | break; | ||
| 83 | case UTVF_RGB24_WIN: | ||
| 84 | avctx->pix_fmt = PIX_FMT_BGR24; | ||
| 85 | break; | ||
| 86 | case UTVF_RGB32_WIN: | ||
| 87 | avctx->pix_fmt = PIX_FMT_RGB32; | ||
| 88 | break; | ||
| 89 | case UTVF_ARGB32_WIN: | ||
| 90 | avctx->pix_fmt = PIX_FMT_ARGB; | ||
| 91 | break; | ||
| 92 | case 0: | ||
| 93 | /* Fall back on FOURCC */ | ||
| 94 | switch(UNFCC(avctx->codec_tag)) | ||
| 95 | { | ||
| 96 | case UTVF_ULY0: | ||
| 97 | avctx->pix_fmt = PIX_FMT_YUV420P; | ||
| 98 | defined_fourcc = UTVF_YV12; | ||
| 99 | break; | ||
| 100 | case UTVF_ULY2: | ||
| 101 | avctx->pix_fmt = PIX_FMT_YUYV422; | ||
| 102 | defined_fourcc = UTVF_YUY2; | ||
| 103 | break; | ||
| 104 | case UTVF_ULRG: | ||
| 105 | avctx->pix_fmt = PIX_FMT_BGR24; | ||
| 106 | defined_fourcc = UTVF_RGB24_WIN; | ||
| 107 | break; | ||
| 108 | case UTVF_ULRA: | ||
| 109 | avctx->pix_fmt = PIX_FMT_RGB32; | ||
| 110 | defined_fourcc = UTVF_RGB32_WIN; | ||
| 111 | break; | ||
| 112 | } | ||
| 113 | break; | ||
| 114 | default: | ||
| 115 | av_log(avctx, AV_LOG_ERROR, | ||
| 116 | "Codec ExtraData is Corrupt or Invalid: %X\n", info.original_format); | ||
| 117 | return -1; | ||
| 118 | } | ||
| 119 | |||
| 120 | /* Only allocate the buffer once */ | ||
| 121 | utv->buf_size = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); | ||
| 122 | utv->output = (uint8_t *)av_malloc(utv->buf_size * sizeof(uint8_t)); | ||
| 123 | |||
| 124 | if(utv->output == NULL) | ||
| 125 | { | ||
| 126 | av_log(avctx, AV_LOG_ERROR, "Unable to allocate output buffer.\n"); | ||
| 127 | return -1; | ||
| 128 | } | ||
| 129 | |||
| 130 | /* Allocate the output frame */ | ||
| 131 | avctx->coded_frame = avcodec_alloc_frame(); | ||
| 132 | |||
| 133 | /* Ut Video only supports 8-bit */ | ||
| 134 | avctx->bits_per_raw_sample = 8; | ||
| 135 | |||
| 136 | /* Is it interlaced? */ | ||
| 137 | avctx->coded_frame->interlaced_frame = info.flags & 0x800 ? 1 : 0; | ||
| 138 | |||
| 139 | /* Apparently Ut Video doesn't store this info... */ | ||
| 140 | avctx->coded_frame->top_field_first = 1; | ||
| 141 | |||
| 142 | /* | ||
| 143 | * Create a Ut Video instance. Since the function wants | ||
| 144 | * an "interface name" string, pass it the name of the lib. | ||
| 145 | */ | ||
| 146 | utv->codec = CCodec::CreateInstance(UNFCC(avctx->codec_tag), "libavcodec"); | ||
| 147 | |||
| 148 | /* Initialize Decoding */ | ||
| 149 | utv->codec->DecodeBegin(defined_fourcc ? defined_fourcc : UNFCC(info.original_format), | ||
| 150 | avctx->width, avctx->height, CBGROSSWIDTH_WINDOWS, &info, | ||
| 151 | sizeof(UtVideoExtra)); | ||
| 152 | |||
| 153 | return 0; | ||
| 154 | } | ||
| 155 | |||
| 156 | static int utvideo_decode_frame(AVCodecContext *avctx, void *data, | ||
| 157 | int *data_size, AVPacket *avpkt) | ||
| 158 | { | ||
| 159 | UtVideoContext *utv = (UtVideoContext *)avctx->priv_data; | ||
| 160 | AVFrame *pic = avctx->coded_frame; | ||
| 161 | unsigned int w = avctx->width, h = avctx->height; | ||
| 162 | |||
| 163 | /* Set flags */ | ||
| 164 | pic->reference = 0; | ||
| 165 | pic->pict_type = AV_PICTURE_TYPE_I; | ||
| 166 | pic->key_frame = 1; | ||
| 167 | |||
| 168 | /* Decode the frame */ | ||
| 169 | utv->codec->DecodeFrame(utv->output, avpkt->data, true); | ||
| 170 | |||
| 171 | /* Set the output data depending on the colorspace */ | ||
| 172 | switch(avctx->pix_fmt) | ||
| 173 | { | ||
| 174 | case PIX_FMT_YUV420P: | ||
| 175 | pic->linesize[0] = w; | ||
| 176 | pic->linesize[1] = pic->linesize[2] = w / 2; | ||
| 177 | pic->data[0] = utv->output; | ||
| 178 | pic->data[2] = utv->output + (w * h); | ||
| 179 | pic->data[1] = pic->data[2] + (w * h / 4); | ||
| 180 | break; | ||
| 181 | case PIX_FMT_YUYV422: | ||
| 182 | case PIX_FMT_UYVY422: | ||
| 183 | pic->linesize[0] = w * 2; | ||
| 184 | pic->data[0] = utv->output; | ||
| 185 | break; | ||
| 186 | case PIX_FMT_BGR24: | ||
| 187 | case PIX_FMT_RGB32: | ||
| 188 | /* Make the linesize negative, since Ut Video uses bottom-up BGR */ | ||
| 189 | pic->linesize[0] = -1 * w * (avctx->pix_fmt == PIX_FMT_BGR24 ? 3 : 4); | ||
| 190 | pic->data[0] = utv->output + utv->buf_size + pic->linesize[0]; | ||
| 191 | break; | ||
| 192 | } | ||
| 193 | |||
| 194 | *data_size = sizeof(AVFrame); | ||
| 195 | *(AVFrame *)data = *pic; | ||
| 196 | |||
| 197 | return avpkt->size; | ||
| 198 | } | ||
| 199 | |||
| 200 | static av_cold int utvideo_decode_close(AVCodecContext *avctx) | ||
| 201 | { | ||
| 202 | UtVideoContext *utv = (UtVideoContext *)avctx->priv_data; | ||
| 203 | |||
| 204 | /* Free output */ | ||
| 205 | av_freep(&avctx->coded_frame); | ||
| 206 | av_freep(&utv->output); | ||
| 207 | |||
| 208 | /* Finish decoding and clean up the instance */ | ||
| 209 | utv->codec->DecodeEnd(); | ||
| 210 | CCodec::DeleteInstance(utv->codec); | ||
| 211 | |||
| 212 | return 0; | ||
| 213 | } | ||
| 214 | |||
| 215 | AVCodec ff_libutvideo_decoder = { | ||
| 216 | "utvideo", | ||
| 217 | AVMEDIA_TYPE_VIDEO, | ||
| 218 | CODEC_ID_UTVIDEO, | ||
| 219 | sizeof(UtVideoContext), | ||
| 220 | utvideo_decode_init, | ||
| 221 | NULL, | ||
| 222 | utvideo_decode_close, | ||
| 223 | utvideo_decode_frame, | ||
| 224 | CODEC_CAP_LOSSLESS, | ||
| 225 | NULL, | ||
| 226 | NULL, | ||
| 227 | NULL, | ||
| 228 | NULL, | ||
| 229 | NULL_IF_CONFIG_SMALL("Ut Video"), | ||
| 230 | }; | ||
| @@ -21,8 +21,8 @@ · 20 unmodified lines | |||
| 21 | #define AVCODEC_VERSION_H | 21 | #define AVCODEC_VERSION_H |
| 22 | 22 | ||
| 23 | #define LIBAVCODEC_VERSION_MAJOR 53 | 23 | #define LIBAVCODEC_VERSION_MAJOR 53 |
| 24 | #define LIBAVCODEC_VERSION_MINOR 20 | 24 | #define LIBAVCODEC_VERSION_MINOR 21 |
| 25 | #define LIBAVCODEC_VERSION_MICRO 1 | 25 | #define LIBAVCODEC_VERSION_MICRO 0 |
| 26 | 26 | ||
| 27 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ | 27 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| 28 | LIBAVCODEC_VERSION_MINOR, \ | 28 | LIBAVCODEC_VERSION_MINOR, \ |
| @@ -281,6 +281,10 @@ const AVCodecTag ff_codec_bmp_tags[] = { · 280 unmodified lines | |||
| 281 | { CODEC_ID_G2M, MKTAG('G', '2', 'M', '3') }, | 281 | { CODEC_ID_G2M, MKTAG('G', '2', 'M', '3') }, |
| 282 | { CODEC_ID_G2M, MKTAG('G', '2', 'M', '4') }, | 282 | { CODEC_ID_G2M, MKTAG('G', '2', 'M', '4') }, |
| 283 | { CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'F') }, | 283 | { CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'F') }, |
| 284 | { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'Y', '0') }, | ||
| 285 | { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'Y', '2') }, | ||
| 286 | { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'R', 'G') }, | ||
| 287 | { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'R', 'A') }, | ||
| 284 | { CODEC_ID_NONE, 0 } | 288 | { CODEC_ID_NONE, 0 } |
| 285 | }; | 289 | }; |
| 286 | 290 | ||