mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-23 04:24:35 +02:00
libutvideo: Add Ut Video Decoder Wrapper
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. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
fe87b2e79c
commit
1de357d6da
5
configure
vendored
5
configure
vendored
@ -185,6 +185,7 @@ External library support:
|
|||||||
--enable-libspeex enable Speex encoding and decoding via libspeex [no]
|
--enable-libspeex enable Speex encoding and decoding via libspeex [no]
|
||||||
--enable-libstagefright-h264 enable H.264 decoding via libstagefright [no]
|
--enable-libstagefright-h264 enable H.264 decoding via libstagefright [no]
|
||||||
--enable-libtheora enable Theora encoding via libtheora [no]
|
--enable-libtheora enable Theora encoding via libtheora [no]
|
||||||
|
--enable-libutvideo enable Ut Video decoding via libutvideo [no]
|
||||||
--enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no]
|
--enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no]
|
||||||
--enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no]
|
--enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no]
|
||||||
--enable-libvorbis enable Vorbis encoding via libvorbis,
|
--enable-libvorbis enable Vorbis encoding via libvorbis,
|
||||||
@ -1015,6 +1016,7 @@ CONFIG_LIST="
|
|||||||
libspeex
|
libspeex
|
||||||
libstagefright_h264
|
libstagefright_h264
|
||||||
libtheora
|
libtheora
|
||||||
|
libutvideo
|
||||||
libvo_aacenc
|
libvo_aacenc
|
||||||
libvo_amrwbenc
|
libvo_amrwbenc
|
||||||
libvorbis
|
libvorbis
|
||||||
@ -1513,6 +1515,7 @@ libvpx_encoder_deps="libvpx"
|
|||||||
libx264_encoder_deps="libx264"
|
libx264_encoder_deps="libx264"
|
||||||
libxavs_encoder_deps="libxavs"
|
libxavs_encoder_deps="libxavs"
|
||||||
libxvid_encoder_deps="libxvid"
|
libxvid_encoder_deps="libxvid"
|
||||||
|
libutvideo_decoder_deps="libutvideo gpl"
|
||||||
|
|
||||||
# demuxers / muxers
|
# demuxers / muxers
|
||||||
ac3_demuxer_select="ac3_parser"
|
ac3_demuxer_select="ac3_parser"
|
||||||
@ -3035,6 +3038,7 @@ enabled libstagefright_h264 && require_cpp libstagefright_h264 "binder/ProcessS
|
|||||||
media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h
|
media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h
|
||||||
media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder
|
media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder
|
||||||
enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
|
enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
|
||||||
|
enabled libutvideo && require_cpp utvideo "stdint.h stdlib.h utvideo/utvideo.h utvideo/Codec.h" 'CCodec*' -lutvideo -lstdc++
|
||||||
enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
|
enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
|
||||||
enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
|
enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
|
||||||
enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
|
enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
|
||||||
@ -3361,6 +3365,7 @@ echo "libschroedinger enabled ${libschroedinger-no}"
|
|||||||
echo "libspeex enabled ${libspeex-no}"
|
echo "libspeex enabled ${libspeex-no}"
|
||||||
echo "libstagefright-h264 enabled ${libstagefright_h264-no}"
|
echo "libstagefright-h264 enabled ${libstagefright_h264-no}"
|
||||||
echo "libtheora enabled ${libtheora-no}"
|
echo "libtheora enabled ${libtheora-no}"
|
||||||
|
echo "libutvideo enabled ${libutvideo-no}"
|
||||||
echo "libvo-aacenc support ${libvo_aacenc-no}"
|
echo "libvo-aacenc support ${libvo_aacenc-no}"
|
||||||
echo "libvo-amrwbenc support ${libvo_amrwbenc-no}"
|
echo "libvo-amrwbenc support ${libvo_amrwbenc-no}"
|
||||||
echo "libvorbis enabled ${libvorbis-no}"
|
echo "libvorbis enabled ${libvorbis-no}"
|
||||||
|
@ -606,6 +606,7 @@ OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o
|
|||||||
OBJS-$(CONFIG_LIBSPEEX_ENCODER) += libspeexenc.o
|
OBJS-$(CONFIG_LIBSPEEX_ENCODER) += libspeexenc.o
|
||||||
OBJS-$(CONFIG_LIBSTAGEFRIGHT_H264_DECODER)+= libstagefright.o
|
OBJS-$(CONFIG_LIBSTAGEFRIGHT_H264_DECODER)+= libstagefright.o
|
||||||
OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o
|
OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o
|
||||||
|
OBJS-$(CONFIG_LIBUTVIDEO_DECODER) += libutvideo.o
|
||||||
OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) += libvo-aacenc.o mpeg4audio.o
|
OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) += libvo-aacenc.o mpeg4audio.o
|
||||||
OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
|
OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
|
||||||
OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o vorbis_data.o
|
OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o vorbis_data.o
|
||||||
|
@ -389,6 +389,7 @@ void avcodec_register_all(void)
|
|||||||
REGISTER_ENCDEC (LIBSPEEX, libspeex);
|
REGISTER_ENCDEC (LIBSPEEX, libspeex);
|
||||||
REGISTER_DECODER (LIBSTAGEFRIGHT_H264, libstagefright_h264);
|
REGISTER_DECODER (LIBSTAGEFRIGHT_H264, libstagefright_h264);
|
||||||
REGISTER_ENCODER (LIBTHEORA, libtheora);
|
REGISTER_ENCODER (LIBTHEORA, libtheora);
|
||||||
|
REGISTER_DECODER (LIBUTVIDEO, libutvideo);
|
||||||
REGISTER_ENCODER (LIBVO_AACENC, libvo_aacenc);
|
REGISTER_ENCODER (LIBVO_AACENC, libvo_aacenc);
|
||||||
REGISTER_ENCODER (LIBVO_AMRWBENC, libvo_amrwbenc);
|
REGISTER_ENCODER (LIBVO_AMRWBENC, libvo_amrwbenc);
|
||||||
REGISTER_ENCODER (LIBVORBIS, libvorbis);
|
REGISTER_ENCODER (LIBVORBIS, libvorbis);
|
||||||
|
@ -212,6 +212,7 @@ enum CodecID {
|
|||||||
CODEC_ID_VC1IMAGE,
|
CODEC_ID_VC1IMAGE,
|
||||||
CODEC_ID_8SVX_RAW,
|
CODEC_ID_8SVX_RAW,
|
||||||
CODEC_ID_G2M,
|
CODEC_ID_G2M,
|
||||||
|
CODEC_ID_UTVIDEO = 0x800,
|
||||||
|
|
||||||
/* various PCM "codecs" */
|
/* various PCM "codecs" */
|
||||||
CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
|
CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
|
||||||
|
230
libavcodec/libutvideo.cpp
Normal file
230
libavcodec/libutvideo.cpp
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2011 Derek Buitenhuis
|
||||||
|
*
|
||||||
|
* This file is part of FFmpeg.
|
||||||
|
*
|
||||||
|
* FFmpeg is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public
|
||||||
|
* License as published by the Free Software Foundation;
|
||||||
|
* version 2 of the License.
|
||||||
|
*
|
||||||
|
* FFmpeg is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with FFmpeg; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Known FOURCCs:
|
||||||
|
* 'ULY0' (YCbCr 4:2:0), 'ULY2' (YCbCr 4:2:2), 'ULRG' (RGB), 'ULRA' (RGBA)
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "avcodec.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <utvideo/utvideo.h>
|
||||||
|
#include <utvideo/Codec.h>
|
||||||
|
|
||||||
|
#include "get_bits.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t version;
|
||||||
|
uint32_t original_format;
|
||||||
|
uint32_t stripes;
|
||||||
|
uint32_t flags;
|
||||||
|
} UtVideoExtra;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
CCodec *codec;
|
||||||
|
unsigned int buf_size;
|
||||||
|
uint8_t *output;
|
||||||
|
} UtVideoContext;
|
||||||
|
|
||||||
|
static av_cold int utvideo_decode_init(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
UtVideoContext *utv = (UtVideoContext *)avctx->priv_data;
|
||||||
|
UtVideoExtra info;
|
||||||
|
int defined_fourcc = 0;
|
||||||
|
|
||||||
|
if(avctx->extradata_size != 4*4)
|
||||||
|
{
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Extradata size mismatch.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read extradata */
|
||||||
|
info.version = AV_RL32(avctx->extradata);
|
||||||
|
info.original_format = AV_RL32(avctx->extradata + 4);
|
||||||
|
info.stripes = AV_RL32(avctx->extradata + 8);
|
||||||
|
info.flags = AV_RL32(avctx->extradata + 12);
|
||||||
|
|
||||||
|
/* Try to output the original format */
|
||||||
|
switch(UNFCC(info.original_format))
|
||||||
|
{
|
||||||
|
case UTVF_YV12:
|
||||||
|
avctx->pix_fmt = PIX_FMT_YUV420P;
|
||||||
|
break;
|
||||||
|
case UTVF_YUY2:
|
||||||
|
case UTVF_YUYV:
|
||||||
|
case UTVF_YUNV:
|
||||||
|
avctx->pix_fmt = PIX_FMT_YUYV422;
|
||||||
|
break;
|
||||||
|
case UTVF_UYVY:
|
||||||
|
case UTVF_UYNV:
|
||||||
|
avctx->pix_fmt = PIX_FMT_UYVY422;
|
||||||
|
break;
|
||||||
|
case UTVF_RGB24_WIN:
|
||||||
|
avctx->pix_fmt = PIX_FMT_BGR24;
|
||||||
|
break;
|
||||||
|
case UTVF_RGB32_WIN:
|
||||||
|
avctx->pix_fmt = PIX_FMT_RGB32;
|
||||||
|
break;
|
||||||
|
case UTVF_ARGB32_WIN:
|
||||||
|
avctx->pix_fmt = PIX_FMT_ARGB;
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
/* Fall back on FOURCC */
|
||||||
|
switch(UNFCC(avctx->codec_tag))
|
||||||
|
{
|
||||||
|
case UTVF_ULY0:
|
||||||
|
avctx->pix_fmt = PIX_FMT_YUV420P;
|
||||||
|
defined_fourcc = UTVF_YV12;
|
||||||
|
break;
|
||||||
|
case UTVF_ULY2:
|
||||||
|
avctx->pix_fmt = PIX_FMT_YUYV422;
|
||||||
|
defined_fourcc = UTVF_YUY2;
|
||||||
|
break;
|
||||||
|
case UTVF_ULRG:
|
||||||
|
avctx->pix_fmt = PIX_FMT_BGR24;
|
||||||
|
defined_fourcc = UTVF_RGB24_WIN;
|
||||||
|
break;
|
||||||
|
case UTVF_ULRA:
|
||||||
|
avctx->pix_fmt = PIX_FMT_RGB32;
|
||||||
|
defined_fourcc = UTVF_RGB32_WIN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
|
"Codec ExtraData is Corrupt or Invalid: %X\n", info.original_format);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Only allocate the buffer once */
|
||||||
|
utv->buf_size = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
|
||||||
|
utv->output = (uint8_t *)av_malloc(utv->buf_size * sizeof(uint8_t));
|
||||||
|
|
||||||
|
if(utv->output == NULL)
|
||||||
|
{
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Unable to allocate output buffer.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate the output frame */
|
||||||
|
avctx->coded_frame = avcodec_alloc_frame();
|
||||||
|
|
||||||
|
/* Ut Video only supports 8-bit */
|
||||||
|
avctx->bits_per_raw_sample = 8;
|
||||||
|
|
||||||
|
/* Is it interlaced? */
|
||||||
|
avctx->coded_frame->interlaced_frame = info.flags & 0x800 ? 1 : 0;
|
||||||
|
|
||||||
|
/* Apparently Ut Video doesn't store this info... */
|
||||||
|
avctx->coded_frame->top_field_first = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a Ut Video instance. Since the function wants
|
||||||
|
* an "interface name" string, pass it the name of the lib.
|
||||||
|
*/
|
||||||
|
utv->codec = CCodec::CreateInstance(UNFCC(avctx->codec_tag), "libavcodec");
|
||||||
|
|
||||||
|
/* Initialize Decoding */
|
||||||
|
utv->codec->DecodeBegin(defined_fourcc ? defined_fourcc : UNFCC(info.original_format),
|
||||||
|
avctx->width, avctx->height, CBGROSSWIDTH_WINDOWS, &info,
|
||||||
|
sizeof(UtVideoExtra));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int utvideo_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
|
int *data_size, AVPacket *avpkt)
|
||||||
|
{
|
||||||
|
UtVideoContext *utv = (UtVideoContext *)avctx->priv_data;
|
||||||
|
AVFrame *pic = avctx->coded_frame;
|
||||||
|
unsigned int w = avctx->width, h = avctx->height;
|
||||||
|
|
||||||
|
/* Set flags */
|
||||||
|
pic->reference = 0;
|
||||||
|
pic->pict_type = AV_PICTURE_TYPE_I;
|
||||||
|
pic->key_frame = 1;
|
||||||
|
|
||||||
|
/* Decode the frame */
|
||||||
|
utv->codec->DecodeFrame(utv->output, avpkt->data, true);
|
||||||
|
|
||||||
|
/* Set the output data depending on the colorspace */
|
||||||
|
switch(avctx->pix_fmt)
|
||||||
|
{
|
||||||
|
case PIX_FMT_YUV420P:
|
||||||
|
pic->linesize[0] = w;
|
||||||
|
pic->linesize[1] = pic->linesize[2] = w / 2;
|
||||||
|
pic->data[0] = utv->output;
|
||||||
|
pic->data[2] = utv->output + (w * h);
|
||||||
|
pic->data[1] = pic->data[2] + (w * h / 4);
|
||||||
|
break;
|
||||||
|
case PIX_FMT_YUYV422:
|
||||||
|
case PIX_FMT_UYVY422:
|
||||||
|
pic->linesize[0] = w * 2;
|
||||||
|
pic->data[0] = utv->output;
|
||||||
|
break;
|
||||||
|
case PIX_FMT_BGR24:
|
||||||
|
case PIX_FMT_RGB32:
|
||||||
|
/* Make the linesize negative, since Ut Video uses bottom-up BGR */
|
||||||
|
pic->linesize[0] = -1 * w * (avctx->pix_fmt == PIX_FMT_BGR24 ? 3 : 4);
|
||||||
|
pic->data[0] = utv->output + utv->buf_size + pic->linesize[0];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*data_size = sizeof(AVFrame);
|
||||||
|
*(AVFrame *)data = *pic;
|
||||||
|
|
||||||
|
return avpkt->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
static av_cold int utvideo_decode_close(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
UtVideoContext *utv = (UtVideoContext *)avctx->priv_data;
|
||||||
|
|
||||||
|
/* Free output */
|
||||||
|
av_freep(&avctx->coded_frame);
|
||||||
|
av_freep(&utv->output);
|
||||||
|
|
||||||
|
/* Finish decoding and clean up the instance */
|
||||||
|
utv->codec->DecodeEnd();
|
||||||
|
CCodec::DeleteInstance(utv->codec);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
AVCodec ff_libutvideo_decoder = {
|
||||||
|
"utvideo",
|
||||||
|
AVMEDIA_TYPE_VIDEO,
|
||||||
|
CODEC_ID_UTVIDEO,
|
||||||
|
sizeof(UtVideoContext),
|
||||||
|
utvideo_decode_init,
|
||||||
|
NULL,
|
||||||
|
utvideo_decode_close,
|
||||||
|
utvideo_decode_frame,
|
||||||
|
CODEC_CAP_LOSSLESS,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL_IF_CONFIG_SMALL("Ut Video"),
|
||||||
|
};
|
@ -21,8 +21,8 @@
|
|||||||
#define AVCODEC_VERSION_H
|
#define AVCODEC_VERSION_H
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_MAJOR 53
|
#define LIBAVCODEC_VERSION_MAJOR 53
|
||||||
#define LIBAVCODEC_VERSION_MINOR 20
|
#define LIBAVCODEC_VERSION_MINOR 21
|
||||||
#define LIBAVCODEC_VERSION_MICRO 1
|
#define LIBAVCODEC_VERSION_MICRO 0
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||||
LIBAVCODEC_VERSION_MINOR, \
|
LIBAVCODEC_VERSION_MINOR, \
|
||||||
|
@ -281,6 +281,10 @@ const AVCodecTag ff_codec_bmp_tags[] = {
|
|||||||
{ CODEC_ID_G2M, MKTAG('G', '2', 'M', '3') },
|
{ CODEC_ID_G2M, MKTAG('G', '2', 'M', '3') },
|
||||||
{ CODEC_ID_G2M, MKTAG('G', '2', 'M', '4') },
|
{ CODEC_ID_G2M, MKTAG('G', '2', 'M', '4') },
|
||||||
{ CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'F') },
|
{ CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'F') },
|
||||||
|
{ CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'Y', '0') },
|
||||||
|
{ CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'Y', '2') },
|
||||||
|
{ CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'R', 'G') },
|
||||||
|
{ CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'R', 'A') },
|
||||||
{ CODEC_ID_NONE, 0 }
|
{ CODEC_ID_NONE, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user