Commit 342c7dfd authored by Kostya Shishkov's avatar Kostya Shishkov

Bink video decoder

Originally committed as revision 21937 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 336ce917
......@@ -51,7 +51,7 @@ version <next>:
- SIPR decoder
- Adobe Filmstrip muxer and demuxer
- RTP depacketization of H.263
- Bink demuxer and Bink Audio decoder
- Bink demuxer and audio/video decoders
- enable symbol versioning by default for linkers that support it
- IFF PBM/ILBM bitmap decoder
- concat protocol
......
......@@ -112,6 +112,7 @@ Codecs:
asv* Michael Niedermayer
atrac3* Benjamin Larsson
bgmc.c, bgmc.h Thilo Borgmann
bink.c Kostya Shishkov
bmp.c Mans Rullgard, Kostya Shishkov
cavs* Stefan Gehrer
celp_filters.* Vitor Sessak
......
......@@ -331,6 +331,8 @@ following image formats are supported:
@item Beam Software VB @tab @tab X
@item Bethesda VID video @tab @tab X
@tab Used in some games from Bethesda Softworks.
@item Bink Video @tab @tab X
@tab Support for version 'b' is missing.
@item Brute Force & Ignorance @tab @tab X
@tab Used in the game Flash Traffic: City of Angels.
@item C93 video @tab @tab X
......
......@@ -65,6 +65,7 @@ OBJS-$(CONFIG_AURA2_DECODER) += aura.o
OBJS-$(CONFIG_AVS_DECODER) += avs.o
OBJS-$(CONFIG_BETHSOFTVID_DECODER) += bethsoftvideo.o
OBJS-$(CONFIG_BFI_DECODER) += bfi.o
OBJS-$(CONFIG_BINK_DECODER) += bink.o binkidct.o
OBJS-$(CONFIG_BINKAUDIO_DCT_DECODER) += binkaudio.o wma.o
OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER) += binkaudio.o wma.o
OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o
......
......@@ -75,6 +75,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (AVS, avs);
REGISTER_DECODER (BETHSOFTVID, bethsoftvid);
REGISTER_DECODER (BFI, bfi);
REGISTER_DECODER (BINK, bink);
REGISTER_ENCDEC (BMP, bmp);
REGISTER_DECODER (C93, c93);
REGISTER_DECODER (CAVS, cavs);
......
......@@ -30,7 +30,7 @@
#include "libavutil/avutil.h"
#define LIBAVCODEC_VERSION_MAJOR 52
#define LIBAVCODEC_VERSION_MINOR 54
#define LIBAVCODEC_VERSION_MINOR 55
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......@@ -1575,6 +1575,7 @@ typedef struct AVCodecContext {
#define FF_IDCT_EA 21
#define FF_IDCT_SIMPLENEON 22
#define FF_IDCT_SIMPLEALPHA 23
#define FF_IDCT_BINK 24
/**
* slice count
......
This diff is collapsed.
This diff is collapsed.
/*
* Bink IDCT algorithm
* Copyright (c) 2009 Kostya Shishkov
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 libavcodec/binkidct.c
* Bink IDCT algorithm
*/
#include "dsputil.h"
#define A1 2896 /* (1/sqrt(2))<<12 */
#define A2 2217
#define A3 3784
#define A4 -5352
#define IDCT_TRANSFORM(dest,s0,s1,s2,s3,s4,s5,s6,s7,d0,d1,d2,d3,d4,d5,d6,d7,munge,src) {\
const int a0 = (src)[s0] + (src)[s4]; \
const int a1 = (src)[s0] - (src)[s4]; \
const int a2 = (src)[s2] + (src)[s6]; \
const int a3 = (A1*((src)[s2] - (src)[s6])) >> 11; \
const int a4 = (src)[s5] + (src)[s3]; \
const int a5 = (src)[s5] - (src)[s3]; \
const int a6 = (src)[s1] + (src)[s7]; \
const int a7 = (src)[s1] - (src)[s7]; \
const int b0 = a4 + a6; \
const int b1 = (A3*(a5 + a7)) >> 11; \
const int b2 = ((A4*a5) >> 11) - b0 + b1; \
const int b3 = (A1*(a6 - a4) >> 11) - b2; \
const int b4 = ((A2*a7) >> 11) + b3 - b1; \
(dest)[d0] = munge(a0+a2 +b0); \
(dest)[d1] = munge(a1+a3-a2+b2); \
(dest)[d2] = munge(a1-a3+a2+b3); \
(dest)[d3] = munge(a0-a2 -b4); \
(dest)[d4] = munge(a0-a2 +b4); \
(dest)[d5] = munge(a1-a3+a2-b3); \
(dest)[d6] = munge(a1+a3-a2-b2); \
(dest)[d7] = munge(a0+a2 -b0); \
}
/* end IDCT_TRANSFORM macro */
#define MUNGE_NONE(x) (x)
#define IDCT_COL(dest,src) IDCT_TRANSFORM(dest,0,8,16,24,32,40,48,56,0,8,16,24,32,40,48,56,MUNGE_NONE,src)
#define MUNGE_ROW(x) (((x) + 0x7F)>>8)
#define IDCT_ROW(dest,src) IDCT_TRANSFORM(dest,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,MUNGE_ROW,src)
static inline void bink_idct_col(DCTELEM *dest, const DCTELEM *src)
{
if ((src[8]|src[16]|src[24]|src[32]|src[40]|src[48]|src[56])==0) {
dest[0] =
dest[8] =
dest[16] =
dest[24] =
dest[32] =
dest[40] =
dest[48] =
dest[56] = src[0];
} else {
IDCT_COL(dest, src);
}
}
void ff_bink_idct_c(DCTELEM *block)
{
int i;
DCTELEM temp[64];
for (i = 0; i < 8; i++)
bink_idct_col(&temp[i], &block[i]);
for (i = 0; i < 8; i++) {
IDCT_ROW( (&block[8*i]), (&temp[8*i]) );
}
}
void ff_bink_idct_add_c(uint8_t *dest, int linesize, DCTELEM *block)
{
int i, j;
ff_bink_idct_c(block);
for (i = 0; i < 8; i++, dest += linesize, block += 8)
for (j = 0; j < 8; j++)
dest[j] += block[j];
}
void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block)
{
int i;
DCTELEM temp[64];
for (i = 0; i < 8; i++)
bink_idct_col(&temp[i], &block[i]);
for (i = 0; i < 8; i++) {
IDCT_ROW( (&dest[i*linesize]), (&temp[8*i]) );
}
}
......@@ -55,6 +55,11 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
/* eaidct.c */
void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
/* binkidct.c */
void ff_bink_idct_c (DCTELEM *block);
void ff_bink_idct_add_c(uint8_t *dest, int linesize, DCTELEM *block);
void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, };
uint32_t ff_squareTbl[512] = {0, };
......@@ -656,6 +661,27 @@ static void put_signed_pixels_clamped_c(const DCTELEM *block,
}
}
static void put_pixels_nonclamped_c(const DCTELEM *block, uint8_t *restrict pixels,
int line_size)
{
int i;
/* read the pixels */
for(i=0;i<8;i++) {
pixels[0] = block[0];
pixels[1] = block[1];
pixels[2] = block[2];
pixels[3] = block[3];
pixels[4] = block[4];
pixels[5] = block[5];
pixels[6] = block[6];
pixels[7] = block[7];
pixels += line_size;
block += 8;
}
}
static void add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
int line_size)
{
......@@ -747,6 +773,42 @@ static int sum_abs_dctelem_c(DCTELEM *block)
return sum;
}
static void fill_block16_c(uint8_t *block, uint8_t value, int line_size, int h)
{
int i;
for (i = 0; i < h; i++) {
memset(block, value, 16);
block += line_size;
}
}
static void fill_block8_c(uint8_t *block, uint8_t value, int line_size, int h)
{
int i;
for (i = 0; i < h; i++) {
memset(block, value, 8);
block += line_size;
}
}
static void scale_block_c(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align 8*/, int linesize)
{
int i, j;
uint16_t *dst1 = dst;
uint16_t *dst2 = dst + linesize;
for (j = 0; j < 8; j++) {
for (i = 0; i < 8; i++) {
dst1[i] = dst2[i] = src[i] * 0x0101;
}
src += 8;
dst1 += linesize;
dst2 += linesize;
}
}
#if 0
#define PIXOP2(OPNAME, OP) \
......@@ -4557,6 +4619,11 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
}else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) {
c->idct_put= ff_ea_idct_put_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else if(CONFIG_BINK_DECODER && avctx->idct_algo==FF_IDCT_BINK) {
c->idct = ff_bink_idct_c;
c->idct_add = ff_bink_idct_add_c;
c->idct_put = ff_bink_idct_put_c;
c->idct_permutation_type = FF_NO_IDCT_PERM;
}else{ //accurate/default
c->idct_put= ff_simple_idct_put;
c->idct_add= ff_simple_idct_add;
......@@ -4580,6 +4647,7 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->diff_pixels = diff_pixels_c;
c->put_pixels_clamped = put_pixels_clamped_c;
c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
c->put_pixels_nonclamped = put_pixels_nonclamped_c;
c->add_pixels_clamped = add_pixels_clamped_c;
c->add_pixels8 = add_pixels8_c;
c->add_pixels4 = add_pixels4_c;
......@@ -4591,6 +4659,10 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->pix_sum = pix_sum_c;
c->pix_norm1 = pix_norm1_c;
c->fill_block_tab[0] = fill_block16_c;
c->fill_block_tab[1] = fill_block8_c;
c->scale_block = scale_block_c;
/* TODO [0] 16 [1] 8 */
c->pix_abs[0][0] = pix_abs16_c;
c->pix_abs[0][1] = pix_abs16_x2_c;
......
......@@ -136,6 +136,8 @@ typedef void (*h264_chroma_mc_func)(uint8_t *dst/*align 8*/, uint8_t *src/*align
typedef void (*h264_weight_func)(uint8_t *block, int stride, int log2_denom, int weight, int offset);
typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset);
typedef void (*op_fill_func)(uint8_t *block/*align width (8 or 16)*/, uint8_t value, int line_size, int h);
#define DEF_OLD_QPEL(name)\
void ff_put_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
void ff_put_no_rnd_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
......@@ -197,6 +199,7 @@ typedef struct DSPContext {
void (*diff_pixels)(DCTELEM *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride);
void (*put_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
void (*put_signed_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
void (*put_pixels_nonclamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
void (*add_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
void (*add_pixels8)(uint8_t *pixels, DCTELEM *block, int line_size);
void (*add_pixels4)(uint8_t *pixels, DCTELEM *block, int line_size);
......@@ -583,6 +586,10 @@ typedef struct DSPContext {
qpel_mc_func avg_rv40_qpel_pixels_tab[4][16];
h264_chroma_mc_func put_rv40_chroma_pixels_tab[3];
h264_chroma_mc_func avg_rv40_chroma_pixels_tab[3];
/* bink functions */
op_fill_func fill_block_tab[2];
void (*scale_block)(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align 8*/, int linesize);
} DSPContext;
void dsputil_static_init(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment