Merge remote-tracking branch 'qatar/master'

* qatar/master:
  snow: split snow in snowdec and snowenc
  tiffenc: deprecate using compression_level
  swscale: fix failing fate tests.
  swscale: add support for planar RGB input.
  h264: add support for decoding planar RGB images.
  Clean up swscale pixfmt macros using av_pix_fmt_descriptors[].
  pixfmt: add planar RGB formats.

Conflicts:
	libavcodec/h264.c
	libavcodec/snow.c
	libavcodec/utils.c
	libavutil/avutil.h
	libavutil/pixdesc.c
	libavutil/pixfmt.h
	libswscale/swscale.c
	libswscale/swscale_internal.h
	libswscale/swscale_unscaled.c
	libswscale/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2011-11-25 01:38:21 +01:00
commit 92afb43162
18 changed files with 3781 additions and 3385 deletions

View File

@ -365,12 +365,12 @@ OBJS-$(CONFIG_SIPR_DECODER) += sipr.o acelp_pitch_delay.o \
OBJS-$(CONFIG_SMACKAUD_DECODER) += smacker.o OBJS-$(CONFIG_SMACKAUD_DECODER) += smacker.o
OBJS-$(CONFIG_SMACKER_DECODER) += smacker.o OBJS-$(CONFIG_SMACKER_DECODER) += smacker.o
OBJS-$(CONFIG_SMC_DECODER) += smc.o OBJS-$(CONFIG_SMC_DECODER) += smc.o
OBJS-$(CONFIG_SNOW_DECODER) += snow.o rangecoder.o OBJS-$(CONFIG_SNOW_DECODER) += snowdec.o snow.o rangecoder.o
OBJS-$(CONFIG_SNOW_ENCODER) += snow.o rangecoder.o motion_est.o \ OBJS-$(CONFIG_SNOW_ENCODER) += snowenc.o snow.o rangecoder.o \
ratecontrol.o h263.o \ motion_est.o ratecontrol.o \
mpegvideo.o error_resilience.o \ h263.o mpegvideo.o \
ituh263enc.o mpegvideo_enc.o \ error_resilience.o ituh263enc.o \
mpeg12data.o mpegvideo_enc.o mpeg12data.o
OBJS-$(CONFIG_SOL_DPCM_DECODER) += dpcm.o OBJS-$(CONFIG_SOL_DPCM_DECODER) += dpcm.o
OBJS-$(CONFIG_SONIC_DECODER) += sonic.o OBJS-$(CONFIG_SONIC_DECODER) += sonic.o
OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o
@ -716,7 +716,7 @@ SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h
SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h
SKIPHEADERS-$(HAVE_W32THREADS) += w32pthreads.h SKIPHEADERS-$(HAVE_W32THREADS) += w32pthreads.h
TESTPROGS = cabac dct fft fft-fixed h264 iirfilter rangecoder snow TESTPROGS = cabac dct fft fft-fixed h264 iirfilter rangecoder snowenc
TESTPROGS-$(HAVE_MMX) += motion TESTPROGS-$(HAVE_MMX) += motion
TESTOBJS = dctref.o TESTOBJS = dctref.o

View File

@ -2781,17 +2781,23 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
switch (h->sps.bit_depth_luma) { switch (h->sps.bit_depth_luma) {
case 9 : case 9 :
if (CHROMA444) if (CHROMA444) {
if (s->avctx->colorspace == AVCOL_SPC_RGB) {
s->avctx->pix_fmt = PIX_FMT_GBRP9;
} else
s->avctx->pix_fmt = PIX_FMT_YUV444P9; s->avctx->pix_fmt = PIX_FMT_YUV444P9;
else if (CHROMA422) } else if (CHROMA422)
s->avctx->pix_fmt = PIX_FMT_YUV422P9; s->avctx->pix_fmt = PIX_FMT_YUV422P9;
else else
s->avctx->pix_fmt = PIX_FMT_YUV420P9; s->avctx->pix_fmt = PIX_FMT_YUV420P9;
break; break;
case 10 : case 10 :
if (CHROMA444) if (CHROMA444) {
if (s->avctx->colorspace == AVCOL_SPC_RGB) {
s->avctx->pix_fmt = PIX_FMT_GBRP10;
} else
s->avctx->pix_fmt = PIX_FMT_YUV444P10; s->avctx->pix_fmt = PIX_FMT_YUV444P10;
else if (CHROMA422) } else if (CHROMA422)
s->avctx->pix_fmt = PIX_FMT_YUV422P10; s->avctx->pix_fmt = PIX_FMT_YUV422P10;
else else
s->avctx->pix_fmt = PIX_FMT_YUV420P10; s->avctx->pix_fmt = PIX_FMT_YUV420P10;

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,10 @@
#include "dsputil.h" #include "dsputil.h"
#include "dwt.h" #include "dwt.h"
#include "rangecoder.h"
#include "mathops.h"
#include "mpegvideo.h"
#define MID_STATE 128 #define MID_STATE 128
#define MAX_PLANES 4 #define MAX_PLANES 4
@ -36,6 +40,138 @@
#define LOG2_OBMC_MAX 8 #define LOG2_OBMC_MAX 8
#define OBMC_MAX (1<<(LOG2_OBMC_MAX)) #define OBMC_MAX (1<<(LOG2_OBMC_MAX))
typedef struct BlockNode{
int16_t mx;
int16_t my;
uint8_t ref;
uint8_t color[3];
uint8_t type;
//#define TYPE_SPLIT 1
#define BLOCK_INTRA 1
#define BLOCK_OPT 2
//#define TYPE_NOCOLOR 4
uint8_t level; //FIXME merge into type?
}BlockNode;
static const BlockNode null_block= { //FIXME add border maybe
.color= {128,128,128},
.mx= 0,
.my= 0,
.ref= 0,
.type= 0,
.level= 0,
};
#define LOG2_MB_SIZE 4
#define MB_SIZE (1<<LOG2_MB_SIZE)
#define ENCODER_EXTRA_BITS 4
#define HTAPS_MAX 8
typedef struct x_and_coeff{
int16_t x;
uint16_t coeff;
} x_and_coeff;
typedef struct SubBand{
int level;
int stride;
int width;
int height;
int qlog; ///< log(qscale)/log[2^(1/6)]
DWTELEM *buf;
IDWTELEM *ibuf;
int buf_x_offset;
int buf_y_offset;
int stride_line; ///< Stride measured in lines, not pixels.
x_and_coeff * x_coeff;
struct SubBand *parent;
uint8_t state[/*7*2*/ 7 + 512][32];
}SubBand;
typedef struct Plane{
int width;
int height;
SubBand band[MAX_DECOMPOSITIONS][4];
int htaps;
int8_t hcoeff[HTAPS_MAX/2];
int diag_mc;
int fast_mc;
int last_htaps;
int8_t last_hcoeff[HTAPS_MAX/2];
int last_diag_mc;
}Plane;
typedef struct SnowContext{
AVClass *class;
AVCodecContext *avctx;
RangeCoder c;
DSPContext dsp;
DWTContext dwt;
AVFrame new_picture;
AVFrame input_picture; ///< new_picture with the internal linesizes
AVFrame current_picture;
AVFrame last_picture[MAX_REF_FRAMES];
uint8_t *halfpel_plane[MAX_REF_FRAMES][4][4];
AVFrame mconly_picture;
// uint8_t q_context[16];
uint8_t header_state[32];
uint8_t block_state[128 + 32*128];
int keyframe;
int always_reset;
int version;
int spatial_decomposition_type;
int last_spatial_decomposition_type;
int temporal_decomposition_type;
int spatial_decomposition_count;
int last_spatial_decomposition_count;
int temporal_decomposition_count;
int max_ref_frames;
int ref_frames;
int16_t (*ref_mvs[MAX_REF_FRAMES])[2];
uint32_t *ref_scores[MAX_REF_FRAMES];
DWTELEM *spatial_dwt_buffer;
IDWTELEM *spatial_idwt_buffer;
int colorspace_type;
int chroma_h_shift;
int chroma_v_shift;
int spatial_scalability;
int qlog;
int last_qlog;
int lambda;
int lambda2;
int pass1_rc;
int mv_scale;
int last_mv_scale;
int qbias;
int last_qbias;
#define QBIAS_SHIFT 3
int b_width;
int b_height;
int block_max_depth;
int last_block_max_depth;
Plane plane[MAX_PLANES];
BlockNode *block;
#define ME_CACHE_SIZE 1024
int me_cache[ME_CACHE_SIZE];
int me_cache_generation;
slice_buffer sb;
int memc_only;
MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX)
uint8_t *scratchbuf;
}SnowContext;
/* Tables */
extern const uint8_t * const obmc_tab[4];
#ifdef __sgi
// Avoid a name clash on SGI IRIX
#undef qexp
#endif
extern uint8_t qexp[QROOT];
extern int scale_mv_ref[MAX_REF_FRAMES][MAX_REF_FRAMES];
/* C bits used by mmx/sse2/altivec */ /* C bits used by mmx/sse2/altivec */
@ -75,4 +211,482 @@ static av_always_inline void snow_horizontal_compose_liftS_lead_out(int i, IDWTE
} }
} }
/* common code */
int ff_snow_common_init(AVCodecContext *avctx);
int ff_snow_common_init_after_header(AVCodecContext *avctx);
void ff_snow_common_end(SnowContext *s);
void ff_snow_release_buffer(AVCodecContext *avctx);
void ff_snow_reset_contexts(SnowContext *s);
int ff_snow_alloc_blocks(SnowContext *s);
int ff_snow_frame_start(SnowContext *s);
void ff_snow_pred_block(SnowContext *s, uint8_t *dst, uint8_t *tmp, int stride,
int sx, int sy, int b_w, int b_h, BlockNode *block,
int plane_index, int w, int h);
/* common inline functions */
//XXX doublecheck all of them should stay inlined
static inline void snow_set_blocks(SnowContext *s, int level, int x, int y, int l, int cb, int cr, int mx, int my, int ref, int type){
const int w= s->b_width << s->block_max_depth;
const int rem_depth= s->block_max_depth - level;
const int index= (x + y*w) << rem_depth;
const int block_w= 1<<rem_depth;
BlockNode block;
int i,j;
block.color[0]= l;
block.color[1]= cb;
block.color[2]= cr;
block.mx= mx;
block.my= my;
block.ref= ref;
block.type= type;
block.level= level;
for(j=0; j<block_w; j++){
for(i=0; i<block_w; i++){
s->block[index + i + j*w]= block;
}
}
}
static inline void pred_mv(SnowContext *s, int *mx, int *my, int ref,
const BlockNode *left, const BlockNode *top, const BlockNode *tr){
if(s->ref_frames == 1){
*mx = mid_pred(left->mx, top->mx, tr->mx);
*my = mid_pred(left->my, top->my, tr->my);
}else{
const int *scale = scale_mv_ref[ref];
*mx = mid_pred((left->mx * scale[left->ref] + 128) >>8,
(top ->mx * scale[top ->ref] + 128) >>8,
(tr ->mx * scale[tr ->ref] + 128) >>8);
*my = mid_pred((left->my * scale[left->ref] + 128) >>8,
(top ->my * scale[top ->ref] + 128) >>8,
(tr ->my * scale[tr ->ref] + 128) >>8);
}
}
static av_always_inline int same_block(BlockNode *a, BlockNode *b){
if((a->type&BLOCK_INTRA) && (b->type&BLOCK_INTRA)){
return !((a->color[0] - b->color[0]) | (a->color[1] - b->color[1]) | (a->color[2] - b->color[2]));
}else{
return !((a->mx - b->mx) | (a->my - b->my) | (a->ref - b->ref) | ((a->type ^ b->type)&BLOCK_INTRA));
}
}
//FIXME name cleanup (b_w, block_w, b_width stuff)
//XXX should we really inline it?
static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer *sb, IDWTELEM *dst, uint8_t *dst8, const uint8_t *obmc, int src_x, int src_y, int b_w, int b_h, int w, int h, int dst_stride, int src_stride, int obmc_stride, int b_x, int b_y, int add, int offset_dst, int plane_index){
const int b_width = s->b_width << s->block_max_depth;
const int b_height= s->b_height << s->block_max_depth;
const int b_stride= b_width;
BlockNode *lt= &s->block[b_x + b_y*b_stride];
BlockNode *rt= lt+1;
BlockNode *lb= lt+b_stride;
BlockNode *rb= lb+1;
uint8_t *block[4];
int tmp_step= src_stride >= 7*MB_SIZE ? MB_SIZE : MB_SIZE*src_stride;
uint8_t *tmp = s->scratchbuf;
uint8_t *ptmp;
int x,y;
if(b_x<0){
lt= rt;
lb= rb;
}else if(b_x + 1 >= b_width){
rt= lt;
rb= lb;
}
if(b_y<0){
lt= lb;
rt= rb;
}else if(b_y + 1 >= b_height){
lb= lt;
rb= rt;
}
if(src_x<0){ //FIXME merge with prev & always round internal width up to *16
obmc -= src_x;
b_w += src_x;
if(!sliced && !offset_dst)
dst -= src_x;
src_x=0;
}else if(src_x + b_w > w){
b_w = w - src_x;
}
if(src_y<0){
obmc -= src_y*obmc_stride;
b_h += src_y;
if(!sliced && !offset_dst)
dst -= src_y*dst_stride;
src_y=0;
}else if(src_y + b_h> h){
b_h = h - src_y;
}
if(b_w<=0 || b_h<=0) return;
assert(src_stride > 2*MB_SIZE + 5);
if(!sliced && offset_dst)
dst += src_x + src_y*dst_stride;
dst8+= src_x + src_y*src_stride;
// src += src_x + src_y*src_stride;
ptmp= tmp + 3*tmp_step;
block[0]= ptmp;
ptmp+=tmp_step;
ff_snow_pred_block(s, block[0], tmp, src_stride, src_x, src_y, b_w, b_h, lt, plane_index, w, h);
if(same_block(lt, rt)){
block[1]= block[0];
}else{
block[1]= ptmp;
ptmp+=tmp_step;
ff_snow_pred_block(s, block[1], tmp, src_stride, src_x, src_y, b_w, b_h, rt, plane_index, w, h);
}
if(same_block(lt, lb)){
block[2]= block[0];
}else if(same_block(rt, lb)){
block[2]= block[1];
}else{
block[2]= ptmp;
ptmp+=tmp_step;
ff_snow_pred_block(s, block[2], tmp, src_stride, src_x, src_y, b_w, b_h, lb, plane_index, w, h);
}
if(same_block(lt, rb) ){
block[3]= block[0];
}else if(same_block(rt, rb)){
block[3]= block[1];
}else if(same_block(lb, rb)){
block[3]= block[2];
}else{
block[3]= ptmp;
ff_snow_pred_block(s, block[3], tmp, src_stride, src_x, src_y, b_w, b_h, rb, plane_index, w, h);
}
if(sliced){
s->dwt.inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
}else{
for(y=0; y<b_h; y++){
//FIXME ugly misuse of obmc_stride
const uint8_t *obmc1= obmc + y*obmc_stride;
const uint8_t *obmc2= obmc1+ (obmc_stride>>1);
const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
const uint8_t *obmc4= obmc3+ (obmc_stride>>1);
for(x=0; x<b_w; x++){
int v= obmc1[x] * block[3][x + y*src_stride]
+obmc2[x] * block[2][x + y*src_stride]
+obmc3[x] * block[1][x + y*src_stride]
+obmc4[x] * block[0][x + y*src_stride];
v <<= 8 - LOG2_OBMC_MAX;
if(FRAC_BITS != 8){
v >>= 8 - FRAC_BITS;
}
if(add){
v += dst[x + y*dst_stride];
v = (v + (1<<(FRAC_BITS-1))) >> FRAC_BITS;
if(v&(~255)) v= ~(v>>31);
dst8[x + y*src_stride] = v;
}else{
dst[x + y*dst_stride] -= v;
}
}
}
}
}
static av_always_inline void predict_slice(SnowContext *s, IDWTELEM *buf, int plane_index, int add, int mb_y){
Plane *p= &s->plane[plane_index];
const int mb_w= s->b_width << s->block_max_depth;
const int mb_h= s->b_height << s->block_max_depth;
int x, y, mb_x;
int block_size = MB_SIZE >> s->block_max_depth;
int block_w = plane_index ? block_size/2 : block_size;
const uint8_t *obmc = plane_index ? obmc_tab[s->block_max_depth+1] : obmc_tab[s->block_max_depth];
const int obmc_stride= plane_index ? block_size : 2*block_size;
int ref_stride= s->current_picture.linesize[plane_index];
uint8_t *dst8= s->current_picture.data[plane_index];
int w= p->width;
int h= p->height;
if(s->keyframe || (s->avctx->debug&512)){
if(mb_y==mb_h)
return;
if(add){
for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++){
for(x=0; x<w; x++){
int v= buf[x + y*w] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1));
v >>= FRAC_BITS;
if(v&(~255)) v= ~(v>>31);
dst8[x + y*ref_stride]= v;
}
}
}else{
for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++){
for(x=0; x<w; x++){
buf[x + y*w]-= 128<<FRAC_BITS;
}
}
}
return;
}
for(mb_x=0; mb_x<=mb_w; mb_x++){
add_yblock(s, 0, NULL, buf, dst8, obmc,
block_w*mb_x - block_w/2,
block_w*mb_y - block_w/2,
block_w, block_w,
w, h,
w, ref_stride, obmc_stride,
mb_x - 1, mb_y - 1,
add, 1, plane_index);
}
}
static av_always_inline void predict_plane(SnowContext *s, IDWTELEM *buf, int plane_index, int add){
const int mb_h= s->b_height << s->block_max_depth;
int mb_y;
for(mb_y=0; mb_y<=mb_h; mb_y++)
predict_slice(s, buf, plane_index, add, mb_y);
}
static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, int cb, int cr, int mx, int my, int ref, int type){
const int w= s->b_width << s->block_max_depth;
const int rem_depth= s->block_max_depth - level;
const int index= (x + y*w) << rem_depth;
const int block_w= 1<<rem_depth;
BlockNode block;
int i,j;
block.color[0]= l;
block.color[1]= cb;
block.color[2]= cr;
block.mx= mx;
block.my= my;
block.ref= ref;
block.type= type;
block.level= level;
for(j=0; j<block_w; j++){
for(i=0; i<block_w; i++){
s->block[index + i + j*w]= block;
}
}
}
static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){
const int offset[3]= {
y*c-> stride + x,
((y*c->uvstride + x)>>1),
((y*c->uvstride + x)>>1),
};
int i;
for(i=0; i<3; i++){
c->src[0][i]= src [i];
c->ref[0][i]= ref [i] + offset[i];
}
assert(!ref_index);
}
/* bitstream functions */
extern const int8_t quant3bA[256];
#define QEXPSHIFT (7-FRAC_BITS+8) //FIXME try to change this to 0
static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed){
int i;
if(v){
const int a= FFABS(v);
const int e= av_log2(a);
const int el= FFMIN(e, 10);
put_rac(c, state+0, 0);
for(i=0; i<el; i++){
put_rac(c, state+1+i, 1); //1..10
}
for(; i<e; i++){
put_rac(c, state+1+9, 1); //1..10
}
put_rac(c, state+1+FFMIN(i,9), 0);
for(i=e-1; i>=el; i--){
put_rac(c, state+22+9, (a>>i)&1); //22..31
}
for(; i>=0; i--){
put_rac(c, state+22+i, (a>>i)&1); //22..31
}
if(is_signed)
put_rac(c, state+11 + el, v < 0); //11..21
}else{
put_rac(c, state+0, 1);
}
}
static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){
if(get_rac(c, state+0))
return 0;
else{
int i, e, a;
e= 0;
while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10
e++;
}
a= 1;
for(i=e-1; i>=0; i--){
a += a + get_rac(c, state+22 + FFMIN(i,9)); //22..31
}
e= -(is_signed && get_rac(c, state+11 + FFMIN(e,10))); //11..21
return (a^e)-e;
}
}
static inline void put_symbol2(RangeCoder *c, uint8_t *state, int v, int log2){
int i;
int r= log2>=0 ? 1<<log2 : 1;
assert(v>=0);
assert(log2>=-4);
while(v >= r){
put_rac(c, state+4+log2, 1);
v -= r;
log2++;
if(log2>0) r+=r;
}
put_rac(c, state+4+log2, 0);
for(i=log2-1; i>=0; i--){
put_rac(c, state+31-i, (v>>i)&1);
}
}
static inline int get_symbol2(RangeCoder *c, uint8_t *state, int log2){
int i;
int r= log2>=0 ? 1<<log2 : 1;
int v=0;
assert(log2>=-4);
while(get_rac(c, state+4+log2)){
v+= r;
log2++;
if(log2>0) r+=r;
}
for(i=log2-1; i>=0; i--){
v+= get_rac(c, state+31-i)<<i;
}
return v;
}
static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, int orientation){
const int w= b->width;
const int h= b->height;
int x,y;
int run, runs;
x_and_coeff *xc= b->x_coeff;
x_and_coeff *prev_xc= NULL;
x_and_coeff *prev2_xc= xc;
x_and_coeff *parent_xc= parent ? parent->x_coeff : NULL;
x_and_coeff *prev_parent_xc= parent_xc;
runs= get_symbol2(&s->c, b->state[30], 0);
if(runs-- > 0) run= get_symbol2(&s->c, b->state[1], 3);
else run= INT_MAX;
for(y=0; y<h; y++){
int v=0;
int lt=0, t=0, rt=0;
if(y && prev_xc->x == 0){
rt= prev_xc->coeff;
}
for(x=0; x<w; x++){
int p=0;
const int l= v;
lt= t; t= rt;
if(y){
if(prev_xc->x <= x)
prev_xc++;
if(prev_xc->x == x + 1)
rt= prev_xc->coeff;
else
rt=0;
}
if(parent_xc){
if(x>>1 > parent_xc->x){
parent_xc++;
}
if(x>>1 == parent_xc->x){
p= parent_xc->coeff;
}
}
if(/*ll|*/l|lt|t|rt|p){
int context= av_log2(/*FFABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1));
v=get_rac(&s->c, &b->state[0][context]);
if(v){
v= 2*(get_symbol2(&s->c, b->state[context + 2], context-4) + 1);
v+=get_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l&0xFF] + 3*quant3bA[t&0xFF]]);
xc->x=x;
(xc++)->coeff= v;
}
}else{
if(!run){
if(runs-- > 0) run= get_symbol2(&s->c, b->state[1], 3);
else run= INT_MAX;
v= 2*(get_symbol2(&s->c, b->state[0 + 2], 0-4) + 1);
v+=get_rac(&s->c, &b->state[0][16 + 1 + 3]);
xc->x=x;
(xc++)->coeff= v;
}else{
int max_run;
run--;
v=0;
if(y) max_run= FFMIN(run, prev_xc->x - x - 2);
else max_run= FFMIN(run, w-x-1);
if(parent_xc)
max_run= FFMIN(max_run, 2*parent_xc->x - x - 1);
x+= max_run;
run-= max_run;
}
}
}
(xc++)->x= w+1; //end marker
prev_xc= prev2_xc;
prev2_xc= xc;
if(parent_xc){
if(y&1){
while(parent_xc->x != parent->width+1)
parent_xc++;
parent_xc++;
prev_parent_xc= parent_xc;
}else{
parent_xc= prev_parent_xc;
}
}
}
(xc++)->x= w+1; //end marker
}
#endif /* AVCODEC_SNOW_H */ #endif /* AVCODEC_SNOW_H */

132
libavcodec/snowdata.h Normal file
View File

@ -0,0 +1,132 @@
/*
* Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at>
* Copyright (C) 2006 Robert Edele <yartrebo@earthlink.net>
*
* This file is part of Libav.
*
* Libav 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.
*
* Libav 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 Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_SNOWDATA_H
#define AVCODEC_SNOWDATA_H
#include "snow.h"
static const uint8_t obmc32[1024]={
0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0,
0, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 16, 20, 20, 20, 24, 24, 20, 20, 20, 16, 16, 16, 12, 12, 8, 8, 8, 4, 4, 4, 0,
0, 4, 8, 8, 12, 12, 16, 20, 20, 24, 28, 28, 32, 32, 36, 40, 40, 36, 32, 32, 28, 28, 24, 20, 20, 16, 12, 12, 8, 8, 4, 0,
0, 4, 8, 12, 16, 20, 24, 28, 28, 32, 36, 40, 44, 48, 52, 56, 56, 52, 48, 44, 40, 36, 32, 28, 28, 24, 20, 16, 12, 8, 4, 0,
4, 8, 12, 16, 20, 24, 28, 32, 40, 44, 48, 52, 56, 60, 64, 68, 68, 64, 60, 56, 52, 48, 44, 40, 32, 28, 24, 20, 16, 12, 8, 4,
4, 8, 12, 20, 24, 32, 36, 40, 48, 52, 56, 64, 68, 76, 80, 84, 84, 80, 76, 68, 64, 56, 52, 48, 40, 36, 32, 24, 20, 12, 8, 4,
4, 8, 16, 24, 28, 36, 44, 48, 56, 60, 68, 76, 80, 88, 96,100,100, 96, 88, 80, 76, 68, 60, 56, 48, 44, 36, 28, 24, 16, 8, 4,
4, 12, 20, 28, 32, 40, 48, 56, 64, 72, 80, 88, 92,100,108,116,116,108,100, 92, 88, 80, 72, 64, 56, 48, 40, 32, 28, 20, 12, 4,
4, 12, 20, 28, 40, 48, 56, 64, 72, 80, 88, 96,108,116,124,132,132,124,116,108, 96, 88, 80, 72, 64, 56, 48, 40, 28, 20, 12, 4,
4, 16, 24, 32, 44, 52, 60, 72, 80, 92,100,108,120,128,136,148,148,136,128,120,108,100, 92, 80, 72, 60, 52, 44, 32, 24, 16, 4,
4, 16, 28, 36, 48, 56, 68, 80, 88,100,112,120,132,140,152,164,164,152,140,132,120,112,100, 88, 80, 68, 56, 48, 36, 28, 16, 4,
4, 16, 28, 40, 52, 64, 76, 88, 96,108,120,132,144,156,168,180,180,168,156,144,132,120,108, 96, 88, 76, 64, 52, 40, 28, 16, 4,
8, 20, 32, 44, 56, 68, 80, 92,108,120,132,144,156,168,180,192,192,180,168,156,144,132,120,108, 92, 80, 68, 56, 44, 32, 20, 8,
8, 20, 32, 48, 60, 76, 88,100,116,128,140,156,168,184,196,208,208,196,184,168,156,140,128,116,100, 88, 76, 60, 48, 32, 20, 8,
8, 20, 36, 52, 64, 80, 96,108,124,136,152,168,180,196,212,224,224,212,196,180,168,152,136,124,108, 96, 80, 64, 52, 36, 20, 8,
8, 24, 40, 56, 68, 84,100,116,132,148,164,180,192,208,224,240,240,224,208,192,180,164,148,132,116,100, 84, 68, 56, 40, 24, 8,
8, 24, 40, 56, 68, 84,100,116,132,148,164,180,192,208,224,240,240,224,208,192,180,164,148,132,116,100, 84, 68, 56, 40, 24, 8,
8, 20, 36, 52, 64, 80, 96,108,124,136,152,168,180,196,212,224,224,212,196,180,168,152,136,124,108, 96, 80, 64, 52, 36, 20, 8,
8, 20, 32, 48, 60, 76, 88,100,116,128,140,156,168,184,196,208,208,196,184,168,156,140,128,116,100, 88, 76, 60, 48, 32, 20, 8,
8, 20, 32, 44, 56, 68, 80, 92,108,120,132,144,156,168,180,192,192,180,168,156,144,132,120,108, 92, 80, 68, 56, 44, 32, 20, 8,
4, 16, 28, 40, 52, 64, 76, 88, 96,108,120,132,144,156,168,180,180,168,156,144,132,120,108, 96, 88, 76, 64, 52, 40, 28, 16, 4,
4, 16, 28, 36, 48, 56, 68, 80, 88,100,112,120,132,140,152,164,164,152,140,132,120,112,100, 88, 80, 68, 56, 48, 36, 28, 16, 4,
4, 16, 24, 32, 44, 52, 60, 72, 80, 92,100,108,120,128,136,148,148,136,128,120,108,100, 92, 80, 72, 60, 52, 44, 32, 24, 16, 4,
4, 12, 20, 28, 40, 48, 56, 64, 72, 80, 88, 96,108,116,124,132,132,124,116,108, 96, 88, 80, 72, 64, 56, 48, 40, 28, 20, 12, 4,
4, 12, 20, 28, 32, 40, 48, 56, 64, 72, 80, 88, 92,100,108,116,116,108,100, 92, 88, 80, 72, 64, 56, 48, 40, 32, 28, 20, 12, 4,
4, 8, 16, 24, 28, 36, 44, 48, 56, 60, 68, 76, 80, 88, 96,100,100, 96, 88, 80, 76, 68, 60, 56, 48, 44, 36, 28, 24, 16, 8, 4,
4, 8, 12, 20, 24, 32, 36, 40, 48, 52, 56, 64, 68, 76, 80, 84, 84, 80, 76, 68, 64, 56, 52, 48, 40, 36, 32, 24, 20, 12, 8, 4,
4, 8, 12, 16, 20, 24, 28, 32, 40, 44, 48, 52, 56, 60, 64, 68, 68, 64, 60, 56, 52, 48, 44, 40, 32, 28, 24, 20, 16, 12, 8, 4,
0, 4, 8, 12, 16, 20, 24, 28, 28, 32, 36, 40, 44, 48, 52, 56, 56, 52, 48, 44, 40, 36, 32, 28, 28, 24, 20, 16, 12, 8, 4, 0,
0, 4, 8, 8, 12, 12, 16, 20, 20, 24, 28, 28, 32, 32, 36, 40, 40, 36, 32, 32, 28, 28, 24, 20, 20, 16, 12, 12, 8, 8, 4, 0,
0, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 16, 20, 20, 20, 24, 24, 20, 20, 20, 16, 16, 16, 12, 12, 8, 8, 8, 4, 4, 4, 0,
0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0,
//error:0.000020
};
static const uint8_t obmc16[256]={
0, 4, 4, 8, 8, 12, 12, 16, 16, 12, 12, 8, 8, 4, 4, 0,
4, 8, 16, 20, 28, 32, 40, 44, 44, 40, 32, 28, 20, 16, 8, 4,
4, 16, 24, 36, 44, 56, 64, 76, 76, 64, 56, 44, 36, 24, 16, 4,
8, 20, 36, 48, 64, 76, 92,104,104, 92, 76, 64, 48, 36, 20, 8,
8, 28, 44, 64, 80,100,116,136,136,116,100, 80, 64, 44, 28, 8,
12, 32, 56, 76,100,120,144,164,164,144,120,100, 76, 56, 32, 12,
12, 40, 64, 92,116,144,168,196,196,168,144,116, 92, 64, 40, 12,
16, 44, 76,104,136,164,196,224,224,196,164,136,104, 76, 44, 16,
16, 44, 76,104,136,164,196,224,224,196,164,136,104, 76, 44, 16,
12, 40, 64, 92,116,144,168,196,196,168,144,116, 92, 64, 40, 12,
12, 32, 56, 76,100,120,144,164,164,144,120,100, 76, 56, 32, 12,
8, 28, 44, 64, 80,100,116,136,136,116,100, 80, 64, 44, 28, 8,
8, 20, 36, 48, 64, 76, 92,104,104, 92, 76, 64, 48, 36, 20, 8,
4, 16, 24, 36, 44, 56, 64, 76, 76, 64, 56, 44, 36, 24, 16, 4,
4, 8, 16, 20, 28, 32, 40, 44, 44, 40, 32, 28, 20, 16, 8, 4,
0, 4, 4, 8, 8, 12, 12, 16, 16, 12, 12, 8, 8, 4, 4, 0,
//error:0.000015
};
//linear *64
static const uint8_t obmc8[64]={
4, 12, 20, 28, 28, 20, 12, 4,
12, 36, 60, 84, 84, 60, 36, 12,
20, 60,100,140,140,100, 60, 20,
28, 84,140,196,196,140, 84, 28,
28, 84,140,196,196,140, 84, 28,
20, 60,100,140,140,100, 60, 20,
12, 36, 60, 84, 84, 60, 36, 12,
4, 12, 20, 28, 28, 20, 12, 4,
//error:0.000000
};
//linear *64
static const uint8_t obmc4[16]={
16, 48, 48, 16,
48,144,144, 48,
48,144,144, 48,
16, 48, 48, 16,
//error:0.000000
};
const int8_t quant3bA[256]={
0, 0, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
};
const uint8_t * const obmc_tab[4]= {
obmc32, obmc16, obmc8, obmc4
};
/* runtime generated tables */
uint8_t qexp[QROOT];
int scale_mv_ref[MAX_REF_FRAMES][MAX_REF_FRAMES];
#endif /* AVCODEC_SNOW_H */

546
libavcodec/snowdec.c Normal file
View File

@ -0,0 +1,546 @@
/*
* Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at>
*
* 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
*/
#include "libavutil/intmath.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "dsputil.h"
#include "dwt.h"
#include "snow.h"
#include "rangecoder.h"
#include "mathops.h"
#include "mpegvideo.h"
#include "h263.h"
#undef NDEBUG
#include <assert.h>
static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer * sb, IDWTELEM * old_buffer, int plane_index, int add, int mb_y){
Plane *p= &s->plane[plane_index];
const int mb_w= s->b_width << s->block_max_depth;
const int mb_h= s->b_height << s->block_max_depth;
int x, y, mb_x;
int block_size = MB_SIZE >> s->block_max_depth;
int block_w = plane_index ? block_size/2 : block_size;
const uint8_t *obmc = plane_index ? obmc_tab[s->block_max_depth+1] : obmc_tab[s->block_max_depth];
int obmc_stride= plane_index ? block_size : 2*block_size;
int ref_stride= s->current_picture.linesize[plane_index];
uint8_t *dst8= s->current_picture.data[plane_index];
int w= p->width;
int h= p->height;
if(s->keyframe || (s->avctx->debug&512)){
if(mb_y==mb_h)
return;
if(add){
for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++){
// DWTELEM * line = slice_buffer_get_line(sb, y);
IDWTELEM * line = sb->line[y];
for(x=0; x<w; x++){
// int v= buf[x + y*w] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1));
int v= line[x] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1));
v >>= FRAC_BITS;
if(v&(~255)) v= ~(v>>31);
dst8[x + y*ref_stride]= v;
}
}
}else{
for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++){
// DWTELEM * line = slice_buffer_get_line(sb, y);
IDWTELEM * line = sb->line[y];
for(x=0; x<w; x++){
line[x] -= 128 << FRAC_BITS;
// buf[x + y*w]-= 128<<FRAC_BITS;
}
}
}
return;
}
for(mb_x=0; mb_x<=mb_w; mb_x++){
add_yblock(s, 1, sb, old_buffer, dst8, obmc,
block_w*mb_x - block_w/2,
block_w*mb_y - block_w/2,
block_w, block_w,
w, h,
w, ref_stride, obmc_stride,
mb_x - 1, mb_y - 1,
add, 0, plane_index);
}
}
static inline void decode_subband_slice_buffered(SnowContext *s, SubBand *b, slice_buffer * sb, int start_y, int h, int save_state[1]){
const int w= b->width;
int y;
const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
int new_index = 0;
if(b->ibuf == s->spatial_idwt_buffer || s->qlog == LOSSLESS_QLOG){
qadd= 0;
qmul= 1<<QEXPSHIFT;
}
/* If we are on the second or later slice, restore our index. */
if (start_y != 0)
new_index = save_state[0];
for(y=start_y; y<h; y++){
int x = 0;
int v;
IDWTELEM * line = slice_buffer_get_line(sb, y * b->stride_line + b->buf_y_offset) + b->buf_x_offset;
memset(line, 0, b->width*sizeof(IDWTELEM));
v = b->x_coeff[new_index].coeff;
x = b->x_coeff[new_index++].x;
while(x < w){
register int t= ( (v>>1)*qmul + qadd)>>QEXPSHIFT;
register int u= -(v&1);
line[x] = (t^u) - u;
v = b->x_coeff[new_index].coeff;
x = b->x_coeff[new_index++].x;
}
}
/* Save our variables for the next slice. */
save_state[0] = new_index;
return;
}
static void decode_q_branch(SnowContext *s, int level, int x, int y){
const int w= s->b_width << s->block_max_depth;
const int rem_depth= s->block_max_depth - level;
const int index= (x + y*w) << rem_depth;
int trx= (x+1)<<rem_depth;
const BlockNode *left = x ? &s->block[index-1] : &null_block;
const BlockNode *top = y ? &s->block[index-w] : &null_block;
const BlockNode *tl = y && x ? &s->block[index-w-1] : left;
const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
int s_context= 2*left->level + 2*top->level + tl->level + tr->level;
if(s->keyframe){
set_blocks(s, level, x, y, null_block.color[0], null_block.color[1], null_block.color[2], null_block.mx, null_block.my, null_block.ref, BLOCK_INTRA);
return;
}
if(level==s->block_max_depth || get_rac(&s->c, &s->block_state[4 + s_context])){
int type, mx, my;
int l = left->color[0];
int cb= left->color[1];
int cr= left->color[2];
int ref = 0;
int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref);
int mx_context= av_log2(2*FFABS(left->mx - top->mx)) + 0*av_log2(2*FFABS(tr->mx - top->mx));
int my_context= av_log2(2*FFABS(left->my - top->my)) + 0*av_log2(2*FFABS(tr->my - top->my));
type= get_rac(&s->c, &s->block_state[1 + left->type + top->type]) ? BLOCK_INTRA : 0;
if(type){
pred_mv(s, &mx, &my, 0, left, top, tr);
l += get_symbol(&s->c, &s->block_state[32], 1);
cb+= get_symbol(&s->c, &s->block_state[64], 1);
cr+= get_symbol(&s->c, &s->block_state[96], 1);
}else{
if(s->ref_frames > 1)
ref= get_symbol(&s->c, &s->block_state[128 + 1024 + 32*ref_context], 0);
pred_mv(s, &mx, &my, ref, left, top, tr);
mx+= get_symbol(&s->c, &s->block_state[128 + 32*(mx_context + 16*!!ref)], 1);
my+= get_symbol(&s->c, &s->block_state[128 + 32*(my_context + 16*!!ref)], 1);
}
set_blocks(s, level, x, y, l, cb, cr, mx, my, ref, type);
}else{
decode_q_branch(s, level+1, 2*x+0, 2*y+0);
decode_q_branch(s, level+1, 2*x+1, 2*y+0);
decode_q_branch(s, level+1, 2*x+0, 2*y+1);
decode_q_branch(s, level+1, 2*x+1, 2*y+1);
}
}
static void dequantize_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, IDWTELEM *src, int stride, int start_y, int end_y){
const int w= b->width;
const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
const int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
int x,y;
if(s->qlog == LOSSLESS_QLOG) return;
for(y=start_y; y<end_y; y++){
// DWTELEM * line = slice_buffer_get_line_from_address(sb, src + (y * stride));
IDWTELEM * line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
for(x=0; x<w; x++){
int i= line[x];
if(i<0){
line[x]= -((-i*qmul + qadd)>>(QEXPSHIFT)); //FIXME try different bias
}else if(i>0){
line[x]= (( i*qmul + qadd)>>(QEXPSHIFT));
}
}
}
}
static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, IDWTELEM *src, int stride, int inverse, int use_median, int start_y, int end_y){
const int w= b->width;
int x,y;
IDWTELEM * line=0; // silence silly "could be used without having been initialized" warning
IDWTELEM * prev;
if (start_y != 0)
line = slice_buffer_get_line(sb, ((start_y - 1) * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
for(y=start_y; y<end_y; y++){
prev = line;
// line = slice_buffer_get_line_from_address(sb, src + (y * stride));
line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
for(x=0; x<w; x++){
if(x){
if(use_median){
if(y && x+1<w) line[x] += mid_pred(line[x - 1], prev[x], prev[x + 1]);
else line[x] += line[x - 1];
}else{
if(y) line[x] += mid_pred(line[x - 1], prev[x], line[x - 1] + prev[x] - prev[x - 1]);
else line[x] += line[x - 1];
}
}else{
if(y) line[x] += prev[x];
}
}
}
}
static void decode_qlogs(SnowContext *s){
int plane_index, level, orientation;
for(plane_index=0; plane_index<3; plane_index++){
for(level=0; level<s->spatial_decomposition_count; level++){
for(orientation=level ? 1:0; orientation<4; orientation++){
int q;
if (plane_index==2) q= s->plane[1].band[level][orientation].qlog;
else if(orientation==2) q= s->plane[plane_index].band[level][1].qlog;
else q= get_symbol(&s->c, s->header_state, 1);
s->plane[plane_index].band[level][orientation].qlog= q;
}
}
}
}
#define GET_S(dst, check) \
tmp= get_symbol(&s->c, s->header_state, 0);\
if(!(check)){\
av_log(s->avctx, AV_LOG_ERROR, "Error " #dst " is %d\n", tmp);\
return -1;\
}\
dst= tmp;
static int decode_header(SnowContext *s){
int plane_index, tmp;
uint8_t kstate[32];
memset(kstate, MID_STATE, sizeof(kstate));
s->keyframe= get_rac(&s->c, kstate);
if(s->keyframe || s->always_reset){
ff_snow_reset_contexts(s);
s->spatial_decomposition_type=
s->qlog=
s->qbias=
s->mv_scale=
s->block_max_depth= 0;
}
if(s->keyframe){
GET_S(s->version, tmp <= 0U)
s->always_reset= get_rac(&s->c, s->header_state);
s->temporal_decomposition_type= get_symbol(&s->c, s->header_state, 0);
s->temporal_decomposition_count= get_symbol(&s->c, s->header_state, 0);
GET_S(s->spatial_decomposition_count, 0 < tmp && tmp <= MAX_DECOMPOSITIONS)
s->colorspace_type= get_symbol(&s->c, s->header_state, 0);
s->chroma_h_shift= get_symbol(&s->c, s->header_state, 0);
s->chroma_v_shift= get_symbol(&s->c, s->header_state, 0);
s->spatial_scalability= get_rac(&s->c, s->header_state);
// s->rate_scalability= get_rac(&s->c, s->header_state);
GET_S(s->max_ref_frames, tmp < (unsigned)MAX_REF_FRAMES)
s->max_ref_frames++;
decode_qlogs(s);
}
if(!s->keyframe){
if(get_rac(&s->c, s->header_state)){
for(plane_index=0; plane_index<2; plane_index++){
int htaps, i, sum=0;
Plane *p= &s->plane[plane_index];
p->diag_mc= get_rac(&s->c, s->header_state);
htaps= get_symbol(&s->c, s->header_state, 0)*2 + 2;
if((unsigned)htaps > HTAPS_MAX || htaps==0)
return -1;
p->htaps= htaps;
for(i= htaps/2; i; i--){
p->hcoeff[i]= get_symbol(&s->c, s->header_state, 0) * (1-2*(i&1));
sum += p->hcoeff[i];
}
p->hcoeff[0]= 32-sum;
}
s->plane[2].diag_mc= s->plane[1].diag_mc;
s->plane[2].htaps = s->plane[1].htaps;
memcpy(s->plane[2].hcoeff, s->plane[1].hcoeff, sizeof(s->plane[1].hcoeff));
}
if(get_rac(&s->c, s->header_state)){
GET_S(s->spatial_decomposition_count, 0 < tmp && tmp <= MAX_DECOMPOSITIONS)
decode_qlogs(s);
}
}
s->spatial_decomposition_type+= get_symbol(&s->c, s->header_state, 1);
if(s->spatial_decomposition_type > 1U){
av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_type %d not supported", s->spatial_decomposition_type);
return -1;
}
if(FFMIN(s->avctx-> width>>s->chroma_h_shift,
s->avctx->height>>s->chroma_v_shift) >> (s->spatial_decomposition_count-1) <= 0){
av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_count %d too large for size", s->spatial_decomposition_count);
return -1;
}
s->qlog += get_symbol(&s->c, s->header_state, 1);
s->mv_scale += get_symbol(&s->c, s->header_state, 1);
s->qbias += get_symbol(&s->c, s->header_state, 1);
s->block_max_depth+= get_symbol(&s->c, s->header_state, 1);
if(s->block_max_depth > 1 || s->block_max_depth < 0){
av_log(s->avctx, AV_LOG_ERROR, "block_max_depth= %d is too large", s->block_max_depth);
s->block_max_depth= 0;
return -1;
}
return 0;
}
static av_cold int decode_init(AVCodecContext *avctx)
{
avctx->pix_fmt= PIX_FMT_YUV420P;
ff_snow_common_init(avctx);
return 0;
}
static void decode_blocks(SnowContext *s){
int x, y;
int w= s->b_width;
int h= s->b_height;
for(y=0; y<h; y++){
for(x=0; x<w; x++){
decode_q_branch(s, 0, x, y);
}
}
}
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt){
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
SnowContext *s = avctx->priv_data;
RangeCoder * const c= &s->c;
int bytes_read;
AVFrame *picture = data;
int level, orientation, plane_index;
ff_init_range_decoder(c, buf, buf_size);
ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
s->current_picture.pict_type= AV_PICTURE_TYPE_I; //FIXME I vs. P
if(decode_header(s)<0)
return -1;
ff_snow_common_init_after_header(avctx);
// realloc slice buffer for the case that spatial_decomposition_count changed
ff_slice_buffer_destroy(&s->sb);
ff_slice_buffer_init(&s->sb, s->plane[0].height, (MB_SIZE >> s->block_max_depth) + s->spatial_decomposition_count * 8 + 1, s->plane[0].width, s->spatial_idwt_buffer);
for(plane_index=0; plane_index<3; plane_index++){
Plane *p= &s->plane[plane_index];
p->fast_mc= p->diag_mc && p->htaps==6 && p->hcoeff[0]==40
&& p->hcoeff[1]==-10
&& p->hcoeff[2]==2;
}
ff_snow_alloc_blocks(s);
if(ff_snow_frame_start(s) < 0)
return -1;
//keyframe flag duplication mess FIXME
if(avctx->debug&FF_DEBUG_PICT_INFO)
av_log(avctx, AV_LOG_ERROR, "keyframe:%d qlog:%d\n", s->keyframe, s->qlog);
decode_blocks(s);
for(plane_index=0; plane_index<3; plane_index++){
Plane *p= &s->plane[plane_index];
int w= p->width;
int h= p->height;
int x, y;
int decode_state[MAX_DECOMPOSITIONS][4][1]; /* Stored state info for unpack_coeffs. 1 variable per instance. */
if(s->avctx->debug&2048){
memset(s->spatial_dwt_buffer, 0, sizeof(DWTELEM)*w*h);
predict_plane(s, s->spatial_idwt_buffer, plane_index, 1);
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int v= s->current_picture.data[plane_index][y*s->current_picture.linesize[plane_index] + x];
s->mconly_picture.data[plane_index][y*s->mconly_picture.linesize[plane_index] + x]= v;
}
}
}
{
for(level=0; level<s->spatial_decomposition_count; level++){
for(orientation=level ? 1 : 0; orientation<4; orientation++){
SubBand *b= &p->band[level][orientation];
unpack_coeffs(s, b, b->parent, orientation);
}
}
}
{
const int mb_h= s->b_height << s->block_max_depth;
const int block_size = MB_SIZE >> s->block_max_depth;
const int block_w = plane_index ? block_size/2 : block_size;
int mb_y;
DWTCompose cs[MAX_DECOMPOSITIONS];
int yd=0, yq=0;
int y;
int end_y;
ff_spatial_idwt_buffered_init(cs, &s->sb, w, h, 1, s->spatial_decomposition_type, s->spatial_decomposition_count);
for(mb_y=0; mb_y<=mb_h; mb_y++){
int slice_starty = block_w*mb_y;
int slice_h = block_w*(mb_y+1);
if (!(s->keyframe || s->avctx->debug&512)){
slice_starty = FFMAX(0, slice_starty - (block_w >> 1));
slice_h -= (block_w >> 1);
}
for(level=0; level<s->spatial_decomposition_count; level++){
for(orientation=level ? 1 : 0; orientation<4; orientation++){
SubBand *b= &p->band[level][orientation];
int start_y;
int end_y;
int our_mb_start = mb_y;
int our_mb_end = (mb_y + 1);
const int extra= 3;
start_y = (mb_y ? ((block_w * our_mb_start) >> (s->spatial_decomposition_count - level)) + s->spatial_decomposition_count - level + extra: 0);
end_y = (((block_w * our_mb_end) >> (s->spatial_decomposition_count - level)) + s->spatial_decomposition_count - level + extra);
if (!(s->keyframe || s->avctx->debug&512)){
start_y = FFMAX(0, start_y - (block_w >> (1+s->spatial_decomposition_count - level)));
end_y = FFMAX(0, end_y - (block_w >> (1+s->spatial_decomposition_count - level)));
}
start_y = FFMIN(b->height, start_y);
end_y = FFMIN(b->height, end_y);
if (start_y != end_y){
if (orientation == 0){
SubBand * correlate_band = &p->band[0][0];
int correlate_end_y = FFMIN(b->height, end_y + 1);
int correlate_start_y = FFMIN(b->height, (start_y ? start_y + 1 : 0));
decode_subband_slice_buffered(s, correlate_band, &s->sb, correlate_start_y, correlate_end_y, decode_state[0][0]);
correlate_slice_buffered(s, &s->sb, correlate_band, correlate_band->ibuf, correlate_band->stride, 1, 0, correlate_start_y, correlate_end_y);
dequantize_slice_buffered(s, &s->sb, correlate_band, correlate_band->ibuf, correlate_band->stride, start_y, end_y);
}
else
decode_subband_slice_buffered(s, b, &s->sb, start_y, end_y, decode_state[level][orientation]);
}
}
}
for(; yd<slice_h; yd+=4){
ff_spatial_idwt_buffered_slice(&s->dwt, cs, &s->sb, w, h, 1, s->spatial_decomposition_type, s->spatial_decomposition_count, yd);
}
if(s->qlog == LOSSLESS_QLOG){
for(; yq<slice_h && yq<h; yq++){
IDWTELEM * line = slice_buffer_get_line(&s->sb, yq);
for(x=0; x<w; x++){
line[x] <<= FRAC_BITS;
}
}
}
predict_slice_buffered(s, &s->sb, s->spatial_idwt_buffer, plane_index, 1, mb_y);
y = FFMIN(p->height, slice_starty);
end_y = FFMIN(p->height, slice_h);
while(y < end_y)
ff_slice_buffer_release(&s->sb, y++);
}
ff_slice_buffer_flush(&s->sb);
}
}
emms_c();
ff_snow_release_buffer(avctx);
if(!(s->avctx->debug&2048))
*picture= s->current_picture;
else
*picture= s->mconly_picture;
*data_size = sizeof(AVFrame);
bytes_read= c->bytestream - c->bytestream_start;
if(bytes_read ==0) av_log(s->avctx, AV_LOG_ERROR, "error at end of frame\n"); //FIXME
return bytes_read;
}
static av_cold int decode_end(AVCodecContext *avctx)
{
SnowContext *s = avctx->priv_data;
ff_slice_buffer_destroy(&s->sb);
ff_snow_common_end(s);
return 0;
}
AVCodec ff_snow_decoder = {
.name = "snow",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_SNOW,
.priv_data_size = sizeof(SnowContext),
.init = decode_init,
.close = decode_end,
.decode = decode_frame,
.capabilities = CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
.long_name = NULL_IF_CONFIG_SMALL("Snow"),
};

2036
libavcodec/snowenc.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -233,6 +233,11 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
p->key_frame = 1; p->key_frame = 1;
avctx->coded_frame= &s->picture; avctx->coded_frame= &s->picture;
#if FF_API_TIFFENC_COMPLEVEL
if (avctx->compression_level != FF_COMPRESSION_DEFAULT)
av_log(avctx, AV_LOG_WARNING, "Using compression_level to set compression "
"algorithm is deprecated. Please use the compression_algo private "
"option instead.\n");
if (avctx->compression_level == 0) { if (avctx->compression_level == 0) {
s->compr = TIFF_RAW; s->compr = TIFF_RAW;
} else if(avctx->compression_level == 2) { } else if(avctx->compression_level == 2) {
@ -242,6 +247,7 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
s->compr = TIFF_DEFLATE; s->compr = TIFF_DEFLATE;
#endif #endif
} }
#endif
s->width = avctx->width; s->width = avctx->width;
s->height = avctx->height; s->height = avctx->height;

View File

@ -138,6 +138,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int l
case PIX_FMT_YUV422P: case PIX_FMT_YUV422P:
case PIX_FMT_YUV440P: case PIX_FMT_YUV440P:
case PIX_FMT_YUV444P: case PIX_FMT_YUV444P:
case PIX_FMT_GBRP:
case PIX_FMT_GRAY8: case PIX_FMT_GRAY8:
case PIX_FMT_GRAY16BE: case PIX_FMT_GRAY16BE:
case PIX_FMT_GRAY16LE: case PIX_FMT_GRAY16LE:
@ -158,7 +159,10 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int l
case PIX_FMT_YUV444P9BE: case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV444P10LE: case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV444P10BE: case PIX_FMT_YUV444P10BE:
case PIX_FMT_GBR24P: case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP10BE:
w_align= 16; //FIXME check for non mpeg style codecs and use less alignment w_align= 16; //FIXME check for non mpeg style codecs and use less alignment
h_align= 16; h_align= 16;
if(s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG || s->codec_id == CODEC_ID_AMV || s->codec_id == CODEC_ID_THP || s->codec_id == CODEC_ID_H264 || s->codec_id == CODEC_ID_PRORES) if(s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG || s->codec_id == CODEC_ID_AMV || s->codec_id == CODEC_ID_THP || s->codec_id == CODEC_ID_H264 || s->codec_id == CODEC_ID_PRORES)

View File

@ -107,5 +107,9 @@
#ifndef FF_API_INTERNAL_CONTEXT #ifndef FF_API_INTERNAL_CONTEXT
#define FF_API_INTERNAL_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 54) #define FF_API_INTERNAL_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 54)
#endif #endif
#ifndef FF_API_TIFFENC_COMPLEVEL
#define FF_API_TIFFENC_COMPLEVEL (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
#endif /* AVCODEC_VERSION_H */ #endif /* AVCODEC_VERSION_H */

View File

@ -153,7 +153,7 @@
*/ */
#define LIBAVUTIL_VERSION_MAJOR 51 #define LIBAVUTIL_VERSION_MAJOR 51
#define LIBAVUTIL_VERSION_MINOR 28 #define LIBAVUTIL_VERSION_MINOR 29
#define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

View File

@ -126,6 +126,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,0,1,0,7}, /* U */ {1,0,1,0,7}, /* U */
{2,0,1,0,7}, /* V */ {2,0,1,0,7}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUYV422] = { [PIX_FMT_YUYV422] = {
.name = "yuyv422", .name = "yuyv422",
@ -148,6 +149,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,2,2,0,7}, /* G */ {0,2,2,0,7}, /* G */
{0,2,3,0,7}, /* B */ {0,2,3,0,7}, /* B */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_BGR24] = { [PIX_FMT_BGR24] = {
.name = "bgr24", .name = "bgr24",
@ -159,6 +161,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,2,2,0,7}, /* G */ {0,2,2,0,7}, /* G */
{0,2,3,0,7}, /* R */ {0,2,3,0,7}, /* R */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_YUV422P] = { [PIX_FMT_YUV422P] = {
.name = "yuv422p", .name = "yuv422p",
@ -170,6 +173,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,0,1,0,7}, /* U */ {1,0,1,0,7}, /* U */
{2,0,1,0,7}, /* V */ {2,0,1,0,7}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV444P] = { [PIX_FMT_YUV444P] = {
.name = "yuv444p", .name = "yuv444p",
@ -181,6 +185,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,0,1,0,7}, /* U */ {1,0,1,0,7}, /* U */
{2,0,1,0,7}, /* V */ {2,0,1,0,7}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV410P] = { [PIX_FMT_YUV410P] = {
.name = "yuv410p", .name = "yuv410p",
@ -192,6 +197,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,0,1,0,7}, /* U */ {1,0,1,0,7}, /* U */
{2,0,1,0,7}, /* V */ {2,0,1,0,7}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV411P] = { [PIX_FMT_YUV411P] = {
.name = "yuv411p", .name = "yuv411p",
@ -203,6 +209,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,0,1,0,7}, /* U */ {1,0,1,0,7}, /* U */
{2,0,1,0,7}, /* V */ {2,0,1,0,7}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_GRAY8] = { [PIX_FMT_GRAY8] = {
.name = "gray", .name = "gray",
@ -212,7 +219,6 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
.comp = { .comp = {
{0,0,1,0,7}, /* Y */ {0,0,1,0,7}, /* Y */
}, },
.flags = PIX_FMT_PAL,
}, },
[PIX_FMT_MONOWHITE] = { [PIX_FMT_MONOWHITE] = {
.name = "monow", .name = "monow",
@ -254,6 +260,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,0,1,0,7}, /* U */ {1,0,1,0,7}, /* U */
{2,0,1,0,7}, /* V */ {2,0,1,0,7}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUVJ422P] = { [PIX_FMT_YUVJ422P] = {
.name = "yuvj422p", .name = "yuvj422p",
@ -265,6 +272,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,0,1,0,7}, /* U */ {1,0,1,0,7}, /* U */
{2,0,1,0,7}, /* V */ {2,0,1,0,7}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUVJ444P] = { [PIX_FMT_YUVJ444P] = {
.name = "yuvj444p", .name = "yuvj444p",
@ -276,6 +284,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,0,1,0,7}, /* U */ {1,0,1,0,7}, /* U */
{2,0,1,0,7}, /* V */ {2,0,1,0,7}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_XVMC_MPEG2_MC] = { [PIX_FMT_XVMC_MPEG2_MC] = {
.name = "xvmcmc", .name = "xvmcmc",
@ -317,7 +326,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,0,1,3,2}, /* G */ {0,0,1,3,2}, /* G */
{0,0,1,0,2}, /* R */ {0,0,1,0,2}, /* R */
}, },
.flags = PIX_FMT_PAL, .flags = PIX_FMT_PAL | PIX_FMT_RGB,
}, },
[PIX_FMT_BGR4] = { [PIX_FMT_BGR4] = {
.name = "bgr4", .name = "bgr4",
@ -329,7 +338,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,3,2,0,1}, /* G */ {0,3,2,0,1}, /* G */
{0,3,4,0,0}, /* R */ {0,3,4,0,0}, /* R */
}, },
.flags = PIX_FMT_BITSTREAM, .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
}, },
[PIX_FMT_BGR4_BYTE] = { [PIX_FMT_BGR4_BYTE] = {
.name = "bgr4_byte", .name = "bgr4_byte",
@ -341,7 +350,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,0,1,1,1}, /* G */ {0,0,1,1,1}, /* G */
{0,0,1,0,0}, /* R */ {0,0,1,0,0}, /* R */
}, },
.flags = PIX_FMT_PAL, .flags = PIX_FMT_PAL | PIX_FMT_RGB,
}, },
[PIX_FMT_RGB8] = { [PIX_FMT_RGB8] = {
.name = "rgb8", .name = "rgb8",
@ -353,7 +362,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,0,1,3,2}, /* G */ {0,0,1,3,2}, /* G */
{0,0,1,0,2}, /* B */ {0,0,1,0,2}, /* B */
}, },
.flags = PIX_FMT_PAL, .flags = PIX_FMT_PAL | PIX_FMT_RGB,
}, },
[PIX_FMT_RGB4] = { [PIX_FMT_RGB4] = {
.name = "rgb4", .name = "rgb4",
@ -365,7 +374,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,3,2,0,1}, /* G */ {0,3,2,0,1}, /* G */
{0,3,4,0,0}, /* B */ {0,3,4,0,0}, /* B */
}, },
.flags = PIX_FMT_BITSTREAM, .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
}, },
[PIX_FMT_RGB4_BYTE] = { [PIX_FMT_RGB4_BYTE] = {
.name = "rgb4_byte", .name = "rgb4_byte",
@ -377,7 +386,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,0,1,1,1}, /* G */ {0,0,1,1,1}, /* G */
{0,0,1,0,0}, /* B */ {0,0,1,0,0}, /* B */
}, },
.flags = PIX_FMT_PAL, .flags = PIX_FMT_PAL | PIX_FMT_RGB,
}, },
[PIX_FMT_NV12] = { [PIX_FMT_NV12] = {
.name = "nv12", .name = "nv12",
@ -389,6 +398,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,7}, /* U */ {1,1,1,0,7}, /* U */
{1,1,2,0,7}, /* V */ {1,1,2,0,7}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_NV21] = { [PIX_FMT_NV21] = {
.name = "nv21", .name = "nv21",
@ -400,6 +410,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,7}, /* V */ {1,1,1,0,7}, /* V */
{1,1,2,0,7}, /* U */ {1,1,2,0,7}, /* U */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_ARGB] = { [PIX_FMT_ARGB] = {
.name = "argb", .name = "argb",
@ -412,6 +423,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,3,3,0,7}, /* G */ {0,3,3,0,7}, /* G */
{0,3,4,0,7}, /* B */ {0,3,4,0,7}, /* B */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_RGBA] = { [PIX_FMT_RGBA] = {
.name = "rgba", .name = "rgba",
@ -424,6 +436,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,3,3,0,7}, /* B */ {0,3,3,0,7}, /* B */
{0,3,4,0,7}, /* A */ {0,3,4,0,7}, /* A */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_ABGR] = { [PIX_FMT_ABGR] = {
.name = "abgr", .name = "abgr",
@ -436,6 +449,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,3,3,0,7}, /* G */ {0,3,3,0,7}, /* G */
{0,3,4,0,7}, /* R */ {0,3,4,0,7}, /* R */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_BGRA] = { [PIX_FMT_BGRA] = {
.name = "bgra", .name = "bgra",
@ -448,6 +462,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,3,3,0,7}, /* R */ {0,3,3,0,7}, /* R */
{0,3,4,0,7}, /* A */ {0,3,4,0,7}, /* A */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_GRAY16BE] = { [PIX_FMT_GRAY16BE] = {
.name = "gray16be", .name = "gray16be",
@ -478,6 +493,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,0,1,0,7}, /* U */ {1,0,1,0,7}, /* U */
{2,0,1,0,7}, /* V */ {2,0,1,0,7}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUVJ440P] = { [PIX_FMT_YUVJ440P] = {
.name = "yuvj440p", .name = "yuvj440p",
@ -489,6 +505,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,0,1,0,7}, /* U */ {1,0,1,0,7}, /* U */
{2,0,1,0,7}, /* V */ {2,0,1,0,7}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUVA420P] = { [PIX_FMT_YUVA420P] = {
.name = "yuva420p", .name = "yuva420p",
@ -501,6 +518,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{2,0,1,0,7}, /* V */ {2,0,1,0,7}, /* V */
{3,0,1,0,7}, /* A */ {3,0,1,0,7}, /* A */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_VDPAU_H264] = { [PIX_FMT_VDPAU_H264] = {
.name = "vdpau_h264", .name = "vdpau_h264",
@ -548,7 +566,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,5,3,0,15}, /* G */ {0,5,3,0,15}, /* G */
{0,5,5,0,15}, /* B */ {0,5,5,0,15}, /* B */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_RGB | PIX_FMT_BE,
}, },
[PIX_FMT_RGB48LE] = { [PIX_FMT_RGB48LE] = {
.name = "rgb48le", .name = "rgb48le",
@ -560,6 +578,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,5,3,0,15}, /* G */ {0,5,3,0,15}, /* G */
{0,5,5,0,15}, /* B */ {0,5,5,0,15}, /* B */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_RGBA64BE] = { [PIX_FMT_RGBA64BE] = {
.name = "rgba64be", .name = "rgba64be",
@ -572,7 +591,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,5,5,0,15}, /* B */ {0,5,5,0,15}, /* B */
{0,5,7,0,15}, /* A */ {0,5,7,0,15}, /* A */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_RGB | PIX_FMT_BE,
}, },
[PIX_FMT_RGBA64LE] = { [PIX_FMT_RGBA64LE] = {
.name = "rgba64le", .name = "rgba64le",
@ -585,6 +604,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,5,5,0,15}, /* B */ {0,5,5,0,15}, /* B */
{0,5,7,0,15}, /* B */ {0,5,7,0,15}, /* B */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_RGB565BE] = { [PIX_FMT_RGB565BE] = {
.name = "rgb565be", .name = "rgb565be",
@ -596,7 +616,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,1,1,5,5}, /* G */ {0,1,1,5,5}, /* G */
{0,1,1,0,4}, /* B */ {0,1,1,0,4}, /* B */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_RGB,
}, },
[PIX_FMT_RGB565LE] = { [PIX_FMT_RGB565LE] = {
.name = "rgb565le", .name = "rgb565le",
@ -608,6 +628,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,1,1,5,5}, /* G */ {0,1,1,5,5}, /* G */
{0,1,1,0,4}, /* B */ {0,1,1,0,4}, /* B */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_RGB555BE] = { [PIX_FMT_RGB555BE] = {
.name = "rgb555be", .name = "rgb555be",
@ -619,7 +640,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,1,1,5,4}, /* G */ {0,1,1,5,4}, /* G */
{0,1,1,0,4}, /* B */ {0,1,1,0,4}, /* B */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_RGB,
}, },
[PIX_FMT_RGB555LE] = { [PIX_FMT_RGB555LE] = {
.name = "rgb555le", .name = "rgb555le",
@ -631,6 +652,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,1,1,5,4}, /* G */ {0,1,1,5,4}, /* G */
{0,1,1,0,4}, /* B */ {0,1,1,0,4}, /* B */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_RGB444BE] = { [PIX_FMT_RGB444BE] = {
.name = "rgb444be", .name = "rgb444be",
@ -642,7 +664,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,1,1,4,3}, /* G */ {0,1,1,4,3}, /* G */
{0,1,1,0,3}, /* B */ {0,1,1,0,3}, /* B */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_RGB,
}, },
[PIX_FMT_RGB444LE] = { [PIX_FMT_RGB444LE] = {
.name = "rgb444le", .name = "rgb444le",
@ -654,6 +676,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,1,1,4,3}, /* G */ {0,1,1,4,3}, /* G */
{0,1,1,0,3}, /* B */ {0,1,1,0,3}, /* B */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_BGR48BE] = { [PIX_FMT_BGR48BE] = {
.name = "bgr48be", .name = "bgr48be",
@ -665,7 +688,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,5,3,0,15}, /* G */ {0,5,3,0,15}, /* G */
{0,5,5,0,15}, /* R */ {0,5,5,0,15}, /* R */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_RGB,
}, },
[PIX_FMT_BGR48LE] = { [PIX_FMT_BGR48LE] = {
.name = "bgr48le", .name = "bgr48le",
@ -677,6 +700,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,5,3,0,15}, /* G */ {0,5,3,0,15}, /* G */
{0,5,5,0,15}, /* R */ {0,5,5,0,15}, /* R */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_BGRA64BE] = { [PIX_FMT_BGRA64BE] = {
.name = "bgra64be", .name = "bgra64be",
@ -713,7 +737,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,1,1,5,5}, /* G */ {0,1,1,5,5}, /* G */
{0,1,1,0,4}, /* R */ {0,1,1,0,4}, /* R */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_RGB,
}, },
[PIX_FMT_BGR565LE] = { [PIX_FMT_BGR565LE] = {
.name = "bgr565le", .name = "bgr565le",
@ -725,6 +749,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,1,1,5,5}, /* G */ {0,1,1,5,5}, /* G */
{0,1,1,0,4}, /* R */ {0,1,1,0,4}, /* R */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_BGR555BE] = { [PIX_FMT_BGR555BE] = {
.name = "bgr555be", .name = "bgr555be",
@ -736,7 +761,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,1,1,5,4}, /* G */ {0,1,1,5,4}, /* G */
{0,1,1,0,4}, /* R */ {0,1,1,0,4}, /* R */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_RGB,
}, },
[PIX_FMT_BGR555LE] = { [PIX_FMT_BGR555LE] = {
.name = "bgr555le", .name = "bgr555le",
@ -748,6 +773,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,1,1,5,4}, /* G */ {0,1,1,5,4}, /* G */
{0,1,1,0,4}, /* R */ {0,1,1,0,4}, /* R */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_BGR444BE] = { [PIX_FMT_BGR444BE] = {
.name = "bgr444be", .name = "bgr444be",
@ -759,7 +785,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,1,1,4,3}, /* G */ {0,1,1,4,3}, /* G */
{0,1,1,0,3}, /* R */ {0,1,1,0,3}, /* R */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_RGB,
}, },
[PIX_FMT_BGR444LE] = { [PIX_FMT_BGR444LE] = {
.name = "bgr444le", .name = "bgr444le",
@ -771,6 +797,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,1,1,4,3}, /* G */ {0,1,1,4,3}, /* G */
{0,1,1,0,3}, /* R */ {0,1,1,0,3}, /* R */
}, },
.flags = PIX_FMT_RGB,
}, },
[PIX_FMT_VAAPI_MOCO] = { [PIX_FMT_VAAPI_MOCO] = {
.name = "vaapi_moco", .name = "vaapi_moco",
@ -806,6 +833,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,8}, /* U */ {1,1,1,0,8}, /* U */
{2,1,1,0,8}, /* V */ {2,1,1,0,8}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV420P9BE] = { [PIX_FMT_YUV420P9BE] = {
.name = "yuv420p9be", .name = "yuv420p9be",
@ -817,7 +845,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,8}, /* U */ {1,1,1,0,8}, /* U */
{2,1,1,0,8}, /* V */ {2,1,1,0,8}, /* V */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV420P10LE] = { [PIX_FMT_YUV420P10LE] = {
.name = "yuv420p10le", .name = "yuv420p10le",
@ -829,6 +857,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,9}, /* U */ {1,1,1,0,9}, /* U */
{2,1,1,0,9}, /* V */ {2,1,1,0,9}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV420P10BE] = { [PIX_FMT_YUV420P10BE] = {
.name = "yuv420p10be", .name = "yuv420p10be",
@ -840,7 +869,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,9}, /* U */ {1,1,1,0,9}, /* U */
{2,1,1,0,9}, /* V */ {2,1,1,0,9}, /* V */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV420P16LE] = { [PIX_FMT_YUV420P16LE] = {
.name = "yuv420p16le", .name = "yuv420p16le",
@ -852,6 +881,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,15}, /* U */ {1,1,1,0,15}, /* U */
{2,1,1,0,15}, /* V */ {2,1,1,0,15}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV420P16BE] = { [PIX_FMT_YUV420P16BE] = {
.name = "yuv420p16be", .name = "yuv420p16be",
@ -863,7 +893,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,15}, /* U */ {1,1,1,0,15}, /* U */
{2,1,1,0,15}, /* V */ {2,1,1,0,15}, /* V */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV422P9LE] = { [PIX_FMT_YUV422P9LE] = {
.name = "yuv422p9le", .name = "yuv422p9le",
@ -875,6 +905,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,8}, /* U */ {1,1,1,0,8}, /* U */
{2,1,1,0,8}, /* V */ {2,1,1,0,8}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV422P9BE] = { [PIX_FMT_YUV422P9BE] = {
.name = "yuv422p9be", .name = "yuv422p9be",
@ -886,7 +917,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,8}, /* U */ {1,1,1,0,8}, /* U */
{2,1,1,0,8}, /* V */ {2,1,1,0,8}, /* V */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV422P10LE] = { [PIX_FMT_YUV422P10LE] = {
.name = "yuv422p10le", .name = "yuv422p10le",
@ -898,6 +929,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,9}, /* U */ {1,1,1,0,9}, /* U */
{2,1,1,0,9}, /* V */ {2,1,1,0,9}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV422P10BE] = { [PIX_FMT_YUV422P10BE] = {
.name = "yuv422p10be", .name = "yuv422p10be",
@ -909,7 +941,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,9}, /* U */ {1,1,1,0,9}, /* U */
{2,1,1,0,9}, /* V */ {2,1,1,0,9}, /* V */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV422P16LE] = { [PIX_FMT_YUV422P16LE] = {
.name = "yuv422p16le", .name = "yuv422p16le",
@ -921,6 +953,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,15}, /* U */ {1,1,1,0,15}, /* U */
{2,1,1,0,15}, /* V */ {2,1,1,0,15}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV422P16BE] = { [PIX_FMT_YUV422P16BE] = {
.name = "yuv422p16be", .name = "yuv422p16be",
@ -932,7 +965,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,15}, /* U */ {1,1,1,0,15}, /* U */
{2,1,1,0,15}, /* V */ {2,1,1,0,15}, /* V */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV444P16LE] = { [PIX_FMT_YUV444P16LE] = {
.name = "yuv444p16le", .name = "yuv444p16le",
@ -944,6 +977,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,15}, /* U */ {1,1,1,0,15}, /* U */
{2,1,1,0,15}, /* V */ {2,1,1,0,15}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV444P16BE] = { [PIX_FMT_YUV444P16BE] = {
.name = "yuv444p16be", .name = "yuv444p16be",
@ -955,7 +989,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,15}, /* U */ {1,1,1,0,15}, /* U */
{2,1,1,0,15}, /* V */ {2,1,1,0,15}, /* V */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV444P10LE] = { [PIX_FMT_YUV444P10LE] = {
.name = "yuv444p10le", .name = "yuv444p10le",
@ -967,6 +1001,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,9}, /* U */ {1,1,1,0,9}, /* U */
{2,1,1,0,9}, /* V */ {2,1,1,0,9}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV444P10BE] = { [PIX_FMT_YUV444P10BE] = {
.name = "yuv444p10be", .name = "yuv444p10be",
@ -978,7 +1013,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,9}, /* U */ {1,1,1,0,9}, /* U */
{2,1,1,0,9}, /* V */ {2,1,1,0,9}, /* V */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV444P9LE] = { [PIX_FMT_YUV444P9LE] = {
.name = "yuv444p9le", .name = "yuv444p9le",
@ -990,6 +1025,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,8}, /* U */ {1,1,1,0,8}, /* U */
{2,1,1,0,8}, /* V */ {2,1,1,0,8}, /* V */
}, },
.flags = PIX_FMT_PLANAR,
}, },
[PIX_FMT_YUV444P9BE] = { [PIX_FMT_YUV444P9BE] = {
.name = "yuv444p9be", .name = "yuv444p9be",
@ -1001,7 +1037,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{1,1,1,0,8}, /* U */ {1,1,1,0,8}, /* U */
{2,1,1,0,8}, /* V */ {2,1,1,0,8}, /* V */
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
}, },
[PIX_FMT_DXVA2_VLD] = { [PIX_FMT_DXVA2_VLD] = {
.name = "dxva2_vld", .name = "dxva2_vld",
@ -1031,6 +1067,91 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
{0,0,1,0,7}, /* G */ {0,0,1,0,7}, /* G */
{2,0,1,0,7}, /* R */ {2,0,1,0,7}, /* R */
}, },
.flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
},
[PIX_FMT_GBRP] = {
.name = "gbrp",
.nb_components= 3,
.log2_chroma_w= 0,
.log2_chroma_h= 0,
.comp = {
{0,0,1,0,7}, /* G */
{1,0,1,0,7}, /* B */
{2,0,1,0,7}, /* R */
},
.flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
},
[PIX_FMT_GBRP9LE] = {
.name = "gbrp9le",
.nb_components= 3,
.log2_chroma_w= 0,
.log2_chroma_h= 0,
.comp = {
{0,1,1,0,8}, /* G */
{1,1,1,0,8}, /* B */
{2,1,1,0,8}, /* R */
},
.flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
},
[PIX_FMT_GBRP9BE] = {
.name = "gbrp9be",
.nb_components= 3,
.log2_chroma_w= 0,
.log2_chroma_h= 0,
.comp = {
{0,1,1,0,8}, /* G */
{1,1,1,0,8}, /* B */
{2,1,1,0,8}, /* R */
},
.flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
},
[PIX_FMT_GBRP10LE] = {
.name = "gbrp10le",
.nb_components= 3,
.log2_chroma_w= 0,
.log2_chroma_h= 0,
.comp = {
{0,1,1,0,9}, /* G */
{1,1,1,0,9}, /* B */
{2,1,1,0,9}, /* R */
},
.flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
},
[PIX_FMT_GBRP10BE] = {
.name = "gbrp10be",
.nb_components= 3,
.log2_chroma_w= 0,
.log2_chroma_h= 0,
.comp = {
{0,1,1,0,9}, /* G */
{1,1,1,0,9}, /* B */
{2,1,1,0,9}, /* R */
},
.flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
},
[PIX_FMT_GBRP16LE] = {
.name = "gbrp16le",
.nb_components= 3,
.log2_chroma_w= 0,
.log2_chroma_h= 0,
.comp = {
{0,1,1,0,15}, /* G */
{1,1,1,0,15}, /* B */
{2,1,1,0,15}, /* R */
},
.flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
},
[PIX_FMT_GBRP16BE] = {
.name = "gbrp16be",
.nb_components= 3,
.log2_chroma_w= 0,
.log2_chroma_h= 0,
.comp = {
{0,1,1,0,15}, /* G */
{1,1,1,0,15}, /* B */
{2,1,1,0,15}, /* R */
},
.flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
}, },
}; };

View File

@ -87,6 +87,8 @@ typedef struct AVPixFmtDescriptor{
#define PIX_FMT_PAL 2 ///< Pixel format has a palette in data[1], values are indexes in this palette. #define PIX_FMT_PAL 2 ///< Pixel format has a palette in data[1], values are indexes in this palette.
#define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end. #define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end.
#define PIX_FMT_HWACCEL 8 ///< Pixel format is an HW accelerated format. #define PIX_FMT_HWACCEL 8 ///< Pixel format is an HW accelerated format.
#define PIX_FMT_PLANAR 16 ///< At least one pixel component is not in the first data plane
#define PIX_FMT_RGB 32 ///< The pixel format contains RGB-like data (as opposed to YUV/grayscale)
/** /**
* The array of all the pixel format descriptors. * The array of all the pixel format descriptors.

View File

@ -155,16 +155,31 @@ enum PixelFormat {
PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
PIX_FMT_VDA_VLD, ///< hardware decoding through VDA PIX_FMT_VDA_VLD, ///< hardware decoding through VDA
#ifdef AV_PIX_FMT_ABI_GIT_MASTER
PIX_FMT_RGBA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian PIX_FMT_RGBA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
PIX_FMT_GBR24P, ///< planar GBR, 24bpp, 8G, 8B, 8R. #endif
PIX_FMT_GBRP, ///< planar GBR 4:4:4 24bpp
PIX_FMT_GBRP9BE, ///< planar GBR 4:4:4 27bpp, big endian
PIX_FMT_GBRP9LE, ///< planar GBR 4:4:4 27bpp, little endian
PIX_FMT_GBRP10BE, ///< planar GBR 4:4:4 30bpp, big endian
PIX_FMT_GBRP10LE, ///< planar GBR 4:4:4 30bpp, little endian
PIX_FMT_GBRP16BE, ///< planar GBR 4:4:4 48bpp, big endian
PIX_FMT_GBRP16LE, ///< planar GBR 4:4:4 48bpp, little endian
#ifndef AV_PIX_FMT_ABI_GIT_MASTER
PIX_FMT_RGBA64BE=0x123, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
#endif
PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
}; };
#define PIX_FMT_Y400A PIX_FMT_GRAY8A #define PIX_FMT_Y400A PIX_FMT_GRAY8A
#define PIX_FMT_GBR24P PIX_FMT_GBRP
#if AV_HAVE_BIGENDIAN #if AV_HAVE_BIGENDIAN
# define PIX_FMT_NE(be, le) PIX_FMT_##be # define PIX_FMT_NE(be, le) PIX_FMT_##be
@ -199,4 +214,8 @@ enum PixelFormat {
#define PIX_FMT_RGBA64 PIX_FMT_NE(RGBA64BE, RGBA64LE) #define PIX_FMT_RGBA64 PIX_FMT_NE(RGBA64BE, RGBA64LE)
#define PIX_FMT_BGRA64 PIX_FMT_NE(BGRA64BE, BGRA64LE) #define PIX_FMT_BGRA64 PIX_FMT_NE(BGRA64BE, BGRA64LE)
#define PIX_FMT_GBRP9 PIX_FMT_NE(GBRP9BE , GBRP9LE)
#define PIX_FMT_GBRP10 PIX_FMT_NE(GBRP10BE, GBRP10LE)
#define PIX_FMT_GBRP16 PIX_FMT_NE(GBRP16BE, GBRP16LE)
#endif /* AVUTIL_PIXFMT_H */ #endif /* AVUTIL_PIXFMT_H */

View File

@ -1968,6 +1968,91 @@ static void rgb24ToUV_half_c(int16_t *dstU, int16_t *dstV, const uint8_t *unused
} }
} }
static void planar_rgb_to_y(uint16_t *dst, const uint8_t *src[4], int width)
{
int i;
for (i = 0; i < width; i++) {
int g = src[0][i];
int b = src[1][i];
int r = src[2][i];
dst[i] = (RY*r + GY*g + BY*b + (0x801<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
}
}
static void planar_rgb16le_to_y(uint8_t *_dst, const uint8_t *_src[4], int width)
{
int i;
const uint16_t **src = (const uint16_t **) _src;
uint16_t *dst = (uint16_t *) _dst;
for (i = 0; i < width; i++) {
int g = AV_RL16(src[0] + i);
int b = AV_RL16(src[1] + i);
int r = AV_RL16(src[2] + i);
dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
}
}
static void planar_rgb16be_to_y(uint8_t *_dst, const uint8_t *_src[4], int width)
{
int i;
const uint16_t **src = (const uint16_t **) _src;
uint16_t *dst = (uint16_t *) _dst;
for (i = 0; i < width; i++) {
int g = AV_RB16(src[0] + i);
int b = AV_RB16(src[1] + i);
int r = AV_RB16(src[2] + i);
dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
}
}
static void planar_rgb_to_uv(uint16_t *dstU, uint16_t *dstV, const uint8_t *src[4], int width)
{
int i;
for (i = 0; i < width; i++) {
int g = src[0][i];
int b = src[1][i];
int r = src[2][i];
dstU[i] = (RU*r + GU*g + BU*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
dstV[i] = (RV*r + GV*g + BV*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
}
}
static void planar_rgb16le_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *_src[4], int width)
{
int i;
const uint16_t **src = (const uint16_t **) _src;
uint16_t *dstU = (uint16_t *) _dstU;
uint16_t *dstV = (uint16_t *) _dstV;
for (i = 0; i < width; i++) {
int g = AV_RL16(src[0] + i);
int b = AV_RL16(src[1] + i);
int r = AV_RL16(src[2] + i);
dstU[i] = (RU * r + GU * g + BU * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
dstV[i] = (RV * r + GV * g + BV * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
}
}
static void planar_rgb16be_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *_src[4], int width)
{
int i;
const uint16_t **src = (const uint16_t **) _src;
uint16_t *dstU = (uint16_t *) _dstU;
uint16_t *dstV = (uint16_t *) _dstV;
for (i = 0; i < width; i++) {
int g = AV_RB16(src[0] + i);
int b = AV_RB16(src[1] + i);
int r = AV_RB16(src[2] + i);
dstU[i] = (RU * r + GU * g + BU * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
dstV[i] = (RV * r + GV * g + BV * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
}
}
static void hScale16To19_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_src, static void hScale16To19_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_src,
const int16_t *filter, const int16_t *filter,
const int16_t *filterPos, int filterSize) const int16_t *filterPos, int filterSize)
@ -2139,8 +2224,7 @@ static void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,
// *** horizontal scale Y line to temp buffer // *** horizontal scale Y line to temp buffer
static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth, static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth,
const uint8_t *src, const uint8_t *src2, const uint8_t *src3, const uint8_t *src_in[4], int srcW, int xInc,
int srcW, int xInc,
const int16_t *hLumFilter, const int16_t *hLumFilter,
const int16_t *hLumFilterPos, int hLumFilterSize, const int16_t *hLumFilterPos, int hLumFilterSize,
uint8_t *formatConvBuffer, uint8_t *formatConvBuffer,
@ -2148,9 +2232,13 @@ static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth,
{ {
void (*toYV12)(uint8_t *, const uint8_t *, const uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12; void (*toYV12)(uint8_t *, const uint8_t *, const uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12;
void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange; void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
const uint8_t *src = src_in[isAlpha ? 3 : 0];
if (toYV12) { if (toYV12) {
toYV12(formatConvBuffer, src, src2, src3, srcW, pal); toYV12(formatConvBuffer, src, src_in[1], src_in[2], srcW, pal);
src= formatConvBuffer;
} else if (c->readLumPlanar && !isAlpha) {
c->readLumPlanar(formatConvBuffer, src_in, srcW);
src = formatConvBuffer; src = formatConvBuffer;
} }
@ -2184,14 +2272,20 @@ static void hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2,
} }
static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth, static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth,
const uint8_t *src0, const uint8_t *src1, const uint8_t *src2, const uint8_t *src_in[4],
int srcW, int xInc, const int16_t *hChrFilter, int srcW, int xInc, const int16_t *hChrFilter,
const int16_t *hChrFilterPos, int hChrFilterSize, const int16_t *hChrFilterPos, int hChrFilterSize,
uint8_t *formatConvBuffer, uint32_t *pal) uint8_t *formatConvBuffer, uint32_t *pal)
{ {
const uint8_t *src1 = src_in[1], *src2 = src_in[2];
if (c->chrToYV12) { if (c->chrToYV12) {
uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW*2+78, 16); uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW*2+78, 16);
c->chrToYV12(formatConvBuffer, buf2, src0, src1, src2, srcW, pal); c->chrToYV12(formatConvBuffer, buf2, src_in[0], src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= buf2;
} else if (c->readChrPlanar) {
uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW*2+78, 16);
c->readChrPlanar(formatConvBuffer, buf2, src_in, srcW);
src1= formatConvBuffer; src1= formatConvBuffer;
src2= buf2; src2= buf2;
} }
@ -2609,20 +2703,22 @@ static int swScale(SwsContext *c, const uint8_t* src[],
//Do horizontal scaling //Do horizontal scaling
while(lastInLumBuf < lastLumSrcY) { while(lastInLumBuf < lastLumSrcY) {
const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; const uint8_t *src1[4] = {
const uint8_t *src2= src[1]+(lastInLumBuf + 1 - srcSliceY)*srcStride[1]; src[0] + (lastInLumBuf + 1 - srcSliceY) * srcStride[0],
const uint8_t *src3= src[2]+(lastInLumBuf + 1 - srcSliceY)*srcStride[2]; src[1] + (lastInLumBuf + 1 - srcSliceY) * srcStride[1],
const uint8_t *src4= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3]; src[2] + (lastInLumBuf + 1 - srcSliceY) * srcStride[2],
src[3] + (lastInLumBuf + 1 - srcSliceY) * srcStride[3],
};
lumBufIndex++; lumBufIndex++;
assert(lumBufIndex < 2*vLumBufSize); assert(lumBufIndex < 2*vLumBufSize);
assert(lastInLumBuf + 1 - srcSliceY < srcSliceH); assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);
assert(lastInLumBuf + 1 - srcSliceY >= 0); assert(lastInLumBuf + 1 - srcSliceY >= 0);
hyscale(c, lumPixBuf[ lumBufIndex ], dstW, src1, src2, src3, srcW, lumXInc, hyscale(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc,
hLumFilter, hLumFilterPos, hLumFilterSize, hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer, formatConvBuffer,
pal, 0); pal, 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
hyscale(c, alpPixBuf[ lumBufIndex ], dstW, src4, NULL, NULL, srcW, hyscale(c, alpPixBuf[ lumBufIndex ], dstW, src1, srcW,
lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize, lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer, formatConvBuffer,
pal, 1); pal, 1);
@ -2631,9 +2727,12 @@ static int swScale(SwsContext *c, const uint8_t* src[],
lumBufIndex, lastInLumBuf); lumBufIndex, lastInLumBuf);
} }
while(lastInChrBuf < lastChrSrcY) { while(lastInChrBuf < lastChrSrcY) {
const uint8_t *src0= src[0]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[0]; const uint8_t *src1[4] = {
const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1]; src[0] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[0],
const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2]; src[1] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[1],
src[2] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[2],
src[3] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[3],
};
chrBufIndex++; chrBufIndex++;
assert(chrBufIndex < 2*vChrBufSize); assert(chrBufIndex < 2*vChrBufSize);
assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH)); assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));
@ -2642,7 +2741,7 @@ static int swScale(SwsContext *c, const uint8_t* src[],
if (c->needs_hcscale) if (c->needs_hcscale)
hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex], hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex],
chrDstW, src0, src1, src2, chrSrcW, chrXInc, chrDstW, src1, chrSrcW, chrXInc,
hChrFilter, hChrFilterPos, hChrFilterSize, hChrFilter, hChrFilterPos, hChrFilterSize,
formatConvBuffer, pal); formatConvBuffer, pal);
lastInChrBuf++; lastInChrBuf++;
@ -2796,6 +2895,13 @@ static av_cold void sws_init_swScale_c(SwsContext *c)
case PIX_FMT_PAL8 : case PIX_FMT_PAL8 :
case PIX_FMT_BGR4_BYTE: case PIX_FMT_BGR4_BYTE:
case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break; case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break;
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP16LE: c->readChrPlanar = planar_rgb16le_to_uv; break;
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10BE:
case PIX_FMT_GBRP16BE: c->readChrPlanar = planar_rgb16be_to_uv; break;
case PIX_FMT_GBRP: c->readChrPlanar = planar_rgb_to_uv; break;
#if HAVE_BIGENDIAN #if HAVE_BIGENDIAN
case PIX_FMT_YUV444P9LE: case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV422P9LE: case PIX_FMT_YUV422P9LE:
@ -2860,13 +2966,20 @@ static av_cold void sws_init_swScale_c(SwsContext *c)
case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_c; break; case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_c; break;
case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_c; break; case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_c; break;
case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_c; break; case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_c; break;
case PIX_FMT_GBR24P : c->chrToYV12 = gbr24pToUV_c; break; // case PIX_FMT_GBR24P : c->chrToYV12 = gbr24pToUV_c; break;
} }
} }
c->lumToYV12 = NULL; c->lumToYV12 = NULL;
c->alpToYV12 = NULL; c->alpToYV12 = NULL;
switch (srcFormat) { switch (srcFormat) {
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP16LE: c->readLumPlanar = planar_rgb16le_to_y; break;
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10BE:
case PIX_FMT_GBRP16BE: c->readLumPlanar = planar_rgb16be_to_y; break;
case PIX_FMT_GBRP: c->readLumPlanar = planar_rgb_to_y; break;
#if HAVE_BIGENDIAN #if HAVE_BIGENDIAN
case PIX_FMT_YUV444P9LE: case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV422P9LE: case PIX_FMT_YUV422P9LE:
@ -2918,7 +3031,7 @@ static av_cold void sws_init_swScale_c(SwsContext *c)
case PIX_FMT_RGB48LE: c->lumToYV12 = rgb48LEToY_c; break; case PIX_FMT_RGB48LE: c->lumToYV12 = rgb48LEToY_c; break;
case PIX_FMT_BGR48BE: c->lumToYV12 = bgr48BEToY_c; break; case PIX_FMT_BGR48BE: c->lumToYV12 = bgr48BEToY_c; break;
case PIX_FMT_BGR48LE: c->lumToYV12 = bgr48LEToY_c; break; case PIX_FMT_BGR48LE: c->lumToYV12 = bgr48LEToY_c; break;
case PIX_FMT_GBR24P : c->lumToYV12 = gbr24pToY_c ; break; // case PIX_FMT_GBR24P : c->lumToYV12 = gbr24pToY_c ; break;
} }
if (c->alpPixBuf) { if (c->alpPixBuf) {
switch (srcFormat) { switch (srcFormat) {

View File

@ -30,6 +30,7 @@
#include "libavutil/avutil.h" #include "libavutil/avutil.h"
#include "libavutil/log.h" #include "libavutil/log.h"
#include "libavutil/pixfmt.h" #include "libavutil/pixfmt.h"
#include "libavutil/pixdesc.h"
#define STR(s) AV_TOSTRING(s) //AV_STRINGIFY is too long #define STR(s) AV_TOSTRING(s) //AV_STRINGIFY is too long
@ -429,6 +430,16 @@ typedef struct SwsContext {
void (*chrToYV12)(uint8_t *dstU, uint8_t *dstV, void (*chrToYV12)(uint8_t *dstU, uint8_t *dstV,
const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3,
int width, uint32_t *pal); ///< Unscaled conversion of chroma planes to YV12 for horizontal scaler. int width, uint32_t *pal); ///< Unscaled conversion of chroma planes to YV12 for horizontal scaler.
/**
* Functions to read planar input, such as planar RGB, and convert
* internally to Y/UV.
*/
/** @{ */
void (*readLumPlanar)(uint8_t *dst, const uint8_t *src[4], int width);
void (*readChrPlanar)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int width);
/** @} */
/** /**
* Scale one horizontal line of input data using a bilinear filter * Scale one horizontal line of input data using a bilinear filter
* to produce one line of output data. Compared to SwsContext->hScale(), * to produce one line of output data. Compared to SwsContext->hScale(),
@ -529,98 +540,41 @@ attribute_deprecated
const char *sws_format_name(enum PixelFormat format); const char *sws_format_name(enum PixelFormat format);
#endif #endif
//FIXME replace this with something faster #define is16BPS(x) \
#define is16BPS(x) ( \ (av_pix_fmt_descriptors[x].comp[0].depth_minus1 == 15)
(x)==PIX_FMT_GRAY16BE \
|| (x)==PIX_FMT_GRAY16LE \
|| (x)==PIX_FMT_BGR48BE \
|| (x)==PIX_FMT_BGR48LE \
|| (x)==PIX_FMT_RGB48BE \
|| (x)==PIX_FMT_RGB48LE \
|| (x)==PIX_FMT_BGRA64BE \
|| (x)==PIX_FMT_BGRA64LE \
|| (x)==PIX_FMT_RGBA64BE \
|| (x)==PIX_FMT_RGBA64LE \
|| (x)==PIX_FMT_YUV420P16LE \
|| (x)==PIX_FMT_YUV422P16LE \
|| (x)==PIX_FMT_YUV444P16LE \
|| (x)==PIX_FMT_YUV420P16BE \
|| (x)==PIX_FMT_YUV422P16BE \
|| (x)==PIX_FMT_YUV444P16BE \
)
#define isNBPS(x) ( \
(x)==PIX_FMT_YUV420P9LE \
|| (x)==PIX_FMT_YUV420P9BE \
|| (x)==PIX_FMT_YUV422P9LE \
|| (x)==PIX_FMT_YUV422P9BE \
|| (x)==PIX_FMT_YUV444P9BE \
|| (x)==PIX_FMT_YUV444P9LE \
|| (x)==PIX_FMT_YUV422P10BE \
|| (x)==PIX_FMT_YUV422P10LE \
|| (x)==PIX_FMT_YUV444P10BE \
|| (x)==PIX_FMT_YUV444P10LE \
|| (x)==PIX_FMT_YUV420P10LE \
|| (x)==PIX_FMT_YUV420P10BE \
|| (x)==PIX_FMT_YUV422P10LE \
|| (x)==PIX_FMT_YUV422P10BE \
)
#define is9_OR_10BPS isNBPS //for ronald
#define isBE(x) ((x)&1)
#define isPlanar8YUV(x) ( \
(x)==PIX_FMT_YUV410P \
|| (x)==PIX_FMT_YUV420P \
|| (x)==PIX_FMT_YUVA420P \
|| (x)==PIX_FMT_YUV411P \
|| (x)==PIX_FMT_YUV422P \
|| (x)==PIX_FMT_YUV444P \
|| (x)==PIX_FMT_YUV440P \
|| (x)==PIX_FMT_NV12 \
|| (x)==PIX_FMT_NV21 \
)
#define isPlanarYUV(x) ( \
isPlanar8YUV(x) \
|| (x)==PIX_FMT_YUV420P9LE \
|| (x)==PIX_FMT_YUV422P9LE \
|| (x)==PIX_FMT_YUV444P9LE \
|| (x)==PIX_FMT_YUV420P10LE \
|| (x)==PIX_FMT_YUV422P10LE \
|| (x)==PIX_FMT_YUV444P10LE \
|| (x)==PIX_FMT_YUV420P16LE \
|| (x)==PIX_FMT_YUV422P10LE \
|| (x)==PIX_FMT_YUV422P16LE \
|| (x)==PIX_FMT_YUV444P16LE \
|| (x)==PIX_FMT_YUV420P9BE \
|| (x)==PIX_FMT_YUV422P9BE \
|| (x)==PIX_FMT_YUV444P9BE \
|| (x)==PIX_FMT_YUV420P10BE \
|| (x)==PIX_FMT_YUV422P10BE \
|| (x)==PIX_FMT_YUV444P10BE \
|| (x)==PIX_FMT_YUV420P16BE \
|| (x)==PIX_FMT_YUV422P10BE \
|| (x)==PIX_FMT_YUV422P16BE \
|| (x)==PIX_FMT_YUV444P16BE \
)
#define isPlanar(x) ( \ #define is9_OR_10BPS(x) \
isPlanarYUV(x) \ (av_pix_fmt_descriptors[x].comp[0].depth_minus1 == 8 || \
|| (x)==PIX_FMT_GBR24P \ av_pix_fmt_descriptors[x].comp[0].depth_minus1 == 9)
)
#define isYUV(x) ( \ #define isNBPS(x) is9_OR_10BPS(x)
(x)==PIX_FMT_UYVY422 \
|| (x)==PIX_FMT_YUYV422 \ #define isBE(x) \
|| isPlanarYUV(x) \ (av_pix_fmt_descriptors[x].flags & PIX_FMT_BE)
)
#define isYUV(x) \
(!(av_pix_fmt_descriptors[x].flags & PIX_FMT_RGB) && \
av_pix_fmt_descriptors[x].nb_components >= 2)
#define isPlanarYUV(x) \
((av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR) && \
isYUV(x))
#define isRGB(x) \
(av_pix_fmt_descriptors[x].flags & PIX_FMT_RGB)
#if 0 // FIXME
#define isGray(x) \
(!(av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) && \
av_pix_fmt_descriptors[x].nb_components <= 2)
#else
#define isGray(x) ( \ #define isGray(x) ( \
(x)==PIX_FMT_GRAY8 \ (x)==PIX_FMT_GRAY8 \
|| (x)==PIX_FMT_GRAY8A \ || (x)==PIX_FMT_GRAY8A \
|| (x)==PIX_FMT_GRAY16BE \ || (x)==PIX_FMT_GRAY16BE \
|| (x)==PIX_FMT_GRAY16LE \ || (x)==PIX_FMT_GRAY16LE \
) )
#define isGray16(x) ( \ #endif
(x)==PIX_FMT_GRAY16BE \
|| (x)==PIX_FMT_GRAY16LE \
)
#define isRGBinInt(x) ( \ #define isRGBinInt(x) ( \
(x)==PIX_FMT_RGB48BE \ (x)==PIX_FMT_RGB48BE \
|| (x)==PIX_FMT_RGB48LE \ || (x)==PIX_FMT_RGB48LE \
@ -661,6 +615,7 @@ const char *sws_format_name(enum PixelFormat format);
|| (x)==PIX_FMT_MONOBLACK \ || (x)==PIX_FMT_MONOBLACK \
|| (x)==PIX_FMT_MONOWHITE \ || (x)==PIX_FMT_MONOWHITE \
) )
#define isRGBinBytes(x) ( \ #define isRGBinBytes(x) ( \
(x)==PIX_FMT_RGB48BE \ (x)==PIX_FMT_RGB48BE \
|| (x)==PIX_FMT_RGB48LE \ || (x)==PIX_FMT_RGB48LE \
@ -679,24 +634,18 @@ const char *sws_format_name(enum PixelFormat format);
|| (x)==PIX_FMT_ABGR \ || (x)==PIX_FMT_ABGR \
|| (x)==PIX_FMT_BGR24 \ || (x)==PIX_FMT_BGR24 \
) )
#define isAnyRGB(x) ( \ #define isAnyRGB(x) ( \
isRGBinInt(x) \ isRGBinInt(x) \
|| isBGRinInt(x) \ || isBGRinInt(x) \
|| (x)==PIX_FMT_GBR24P \ || (x)==PIX_FMT_GBR24P \
) )
#define isALPHA(x) ( \
(x)==PIX_FMT_BGRA64BE \ #define isALPHA(x) \
|| (x)==PIX_FMT_BGRA64LE \ (av_pix_fmt_descriptors[x].nb_components == 2 || \
|| (x)==PIX_FMT_RGBA64BE \ av_pix_fmt_descriptors[x].nb_components == 4)
|| (x)==PIX_FMT_RGBA64LE \
|| (x)==PIX_FMT_BGR32 \ #if 1
|| (x)==PIX_FMT_BGR32_1 \
|| (x)==PIX_FMT_RGB32 \
|| (x)==PIX_FMT_RGB32_1 \
|| (x)==PIX_FMT_PAL8 \
|| (x)==PIX_FMT_GRAY8A \
|| (x)==PIX_FMT_YUVA420P \
)
#define isPacked(x) ( \ #define isPacked(x) ( \
(x)==PIX_FMT_PAL8 \ (x)==PIX_FMT_PAL8 \
|| (x)==PIX_FMT_YUYV422 \ || (x)==PIX_FMT_YUYV422 \
@ -705,7 +654,17 @@ const char *sws_format_name(enum PixelFormat format);
|| isRGBinInt(x) \ || isRGBinInt(x) \
|| isBGRinInt(x) \ || isBGRinInt(x) \
) )
#define usePal(x) ((av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) || (x) == PIX_FMT_GRAY8A) #else
#define isPacked(x) \
(av_pix_fmt_descriptors[x].nb_components >= 2 && \
!(av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR))
#endif
#define isPlanar(x) \
(av_pix_fmt_descriptors[x].nb_components >= 2 && \
(av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR))
#define usePal(x) ((av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) || (x) == PIX_FMT_Y400A)
extern const uint64_t ff_dither4[2]; extern const uint64_t ff_dither4[2];
extern const uint64_t ff_dither8[2]; extern const uint64_t ff_dither8[2];

View File

@ -145,6 +145,13 @@ const static FormatEntry format_entries[PIX_FMT_NB] = {
[PIX_FMT_YUV444P10BE] = { 1 , 1 }, [PIX_FMT_YUV444P10BE] = { 1 , 1 },
[PIX_FMT_YUV444P10LE] = { 1 , 1 }, [PIX_FMT_YUV444P10LE] = { 1 , 1 },
[PIX_FMT_GBR24P] = { 1 , 0 }, [PIX_FMT_GBR24P] = { 1 , 0 },
[PIX_FMT_GBRP] = { 1 , 0 },
[PIX_FMT_GBRP9LE] = { 1 , 0 },
[PIX_FMT_GBRP9BE] = { 1 , 0 },
[PIX_FMT_GBRP10LE] = { 1 , 0 },
[PIX_FMT_GBRP10BE] = { 1 , 0 },
[PIX_FMT_GBRP16LE] = { 1 , 0 },
[PIX_FMT_GBRP16BE] = { 1 , 0 },
}; };
int sws_isSupportedInput(enum PixelFormat pix_fmt) int sws_isSupportedInput(enum PixelFormat pix_fmt)