43 const uint8_t *obmc1= obmc + y*obmc_stride;
44 const uint8_t *obmc2= obmc1+ (obmc_stride>>1);
45 const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
49 int v= obmc1[x] *
block[3][x + y*src_stride]
50 +obmc2[x] *
block[2][x + y*src_stride]
51 +obmc3[x] *
block[1][x + y*src_stride]
61 if(v&(~255)) v= ~(v>>31);
62 dst8[x + y*src_stride] = v;
98 int plane_index,
level, orientation;
100 for(plane_index=0; plane_index<3; plane_index++){
102 for(orientation=
level ? 1:0; orientation<4; orientation++){
103 memset(
s->plane[plane_index].band[
level][orientation].state,
MID_STATE,
sizeof(
s->plane[plane_index].band[
level][orientation].state));
107 memset(
s->header_state,
MID_STATE,
sizeof(
s->header_state));
108 memset(
s->block_state,
MID_STATE,
sizeof(
s->block_state));
132 v *= pow(2, 1.0 /
QROOT);
147 static const uint8_t brane[256]={
148 0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x11,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
149 0x04,0x05,0xcc,0xcc,0xcc,0xcc,0xcc,0x41,0x15,0x16,0xcc,0xcc,0xcc,0xcc,0xcc,0x52,
150 0x04,0xcc,0x05,0xcc,0xcc,0xcc,0x41,0xcc,0x15,0xcc,0x16,0xcc,0xcc,0xcc,0x52,0xcc,
151 0x04,0xcc,0xcc,0x05,0xcc,0x41,0xcc,0xcc,0x15,0xcc,0xcc,0x16,0xcc,0x52,0xcc,0xcc,
152 0x04,0xcc,0xcc,0xcc,0x41,0xcc,0xcc,0xcc,0x15,0xcc,0xcc,0xcc,0x16,0xcc,0xcc,0xcc,
153 0x04,0xcc,0xcc,0x41,0xcc,0x05,0xcc,0xcc,0x15,0xcc,0xcc,0x52,0xcc,0x16,0xcc,0xcc,
154 0x04,0xcc,0x41,0xcc,0xcc,0xcc,0x05,0xcc,0x15,0xcc,0x52,0xcc,0xcc,0xcc,0x16,0xcc,
155 0x04,0x41,0xcc,0xcc,0xcc,0xcc,0xcc,0x05,0x15,0x52,0xcc,0xcc,0xcc,0xcc,0xcc,0x16,
156 0x44,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x55,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
157 0x48,0x49,0xcc,0xcc,0xcc,0xcc,0xcc,0x85,0x59,0x5A,0xcc,0xcc,0xcc,0xcc,0xcc,0x96,
158 0x48,0xcc,0x49,0xcc,0xcc,0xcc,0x85,0xcc,0x59,0xcc,0x5A,0xcc,0xcc,0xcc,0x96,0xcc,
159 0x48,0xcc,0xcc,0x49,0xcc,0x85,0xcc,0xcc,0x59,0xcc,0xcc,0x5A,0xcc,0x96,0xcc,0xcc,
160 0x48,0xcc,0xcc,0xcc,0x49,0xcc,0xcc,0xcc,0x59,0xcc,0xcc,0xcc,0x96,0xcc,0xcc,0xcc,
161 0x48,0xcc,0xcc,0x85,0xcc,0x49,0xcc,0xcc,0x59,0xcc,0xcc,0x96,0xcc,0x5A,0xcc,0xcc,
162 0x48,0xcc,0x85,0xcc,0xcc,0xcc,0x49,0xcc,0x59,0xcc,0x96,0xcc,0xcc,0xcc,0x5A,0xcc,
163 0x48,0x85,0xcc,0xcc,0xcc,0xcc,0xcc,0x49,0x59,0x96,0xcc,0xcc,0xcc,0xcc,0xcc,0x5A,
166 static const uint8_t needs[16]={
176 int16_t *tmpI= tmpIt;
180 r= brane[dx + 16*dy]&15;
181 l= brane[dx + 16*dy]>>4;
183 b= needs[l] | needs[
r];
189 for(x=0; x < b_w; x++){
209 if(am&(~255)) am= ~(am>>31);
222 for(y=0; y < b_h; y++){
223 for(x=0; x < b_w+1; x++){
238 if(am&(~255)) am= ~(am>>31);
250 for(y=0; y < b_h; y++){
251 for(x=0; x < b_w; x++){
265 if(am&(~255)) am= ~(am>>31);
279 hpel[ 6]= tmp2t[1] + 1;
282 hpel[ 9]= hpel[1] + 64;
283 hpel[10]= hpel[8] + 1;
285 #define MC_STRIDE(x) (needs[x] ? 64 : stride)
288 int dxy = dx / 8 + dy / 8 * 4;
290 const uint8_t *src2 = hpel[dxy + 1];
291 const uint8_t *src3 = hpel[dxy + 4];
292 const uint8_t *src4 = hpel[dxy + 5];
299 for(y=0; y < b_h; y++){
300 for(x=0; x < b_w; x++){
301 dst[x]= ((8-dx)*(8-dy)*
src1[x] + dx*(8-dy)*src2[x]+
302 (8-dx)* dy *src3[x] + dx* dy *src4[x]+32)>>6;
315 int a=
weight[((dx&7) + (8*(dy&7)))];
317 for(y=0; y < b_h; y++){
318 for(x=0; x < b_w; x++){
319 dst[x]= (
a*
src1[x] +
b*src2[x] + 4)>>3;
328 void ff_snow_pred_block(
SnowContext *
s,
uint8_t *dst,
uint8_t *
tmp, ptrdiff_t
stride,
int sx,
int sy,
int b_w,
int b_h,
const BlockNode *
block,
int plane_index,
int w,
int h){
331 const unsigned color =
block->color[plane_index];
332 const unsigned color4 =
color*0x01010101;
334 for(y=0; y < b_h; y++){
335 *(uint32_t*)&dst[0 + y*
stride]= color4;
336 *(uint32_t*)&dst[4 + y*
stride]= color4;
337 *(uint32_t*)&dst[8 + y*
stride]= color4;
338 *(uint32_t*)&dst[12+ y*
stride]= color4;
339 *(uint32_t*)&dst[16+ y*
stride]= color4;
340 *(uint32_t*)&dst[20+ y*
stride]= color4;
341 *(uint32_t*)&dst[24+ y*
stride]= color4;
342 *(uint32_t*)&dst[28+ y*
stride]= color4;
345 for(y=0; y < b_h; y++){
346 *(uint32_t*)&dst[0 + y*
stride]= color4;
347 *(uint32_t*)&dst[4 + y*
stride]= color4;
348 *(uint32_t*)&dst[8 + y*
stride]= color4;
349 *(uint32_t*)&dst[12+ y*
stride]= color4;
352 for(y=0; y < b_h; y++){
353 *(uint32_t*)&dst[0 + y*
stride]= color4;
354 *(uint32_t*)&dst[4 + y*
stride]= color4;
357 for(y=0; y < b_h; y++){
358 *(uint32_t*)&dst[0 + y*
stride]= color4;
361 for(y=0; y < b_h; y++){
362 for(x=0; x < b_w; x++){
369 const int scale= plane_index ? (2*
s->mv_scale)>>
s->chroma_h_shift : 2*
s->mv_scale;
370 int mx=
block->mx*scale;
371 int my=
block->my*scale;
374 const int tab_index= 3 - (b_w>>2) + (b_w>>4);
389 av_assert2((tab_index>=0 && tab_index<4) || b_w==32);
391 || !(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h)
395 || !
s->plane[plane_index].fast_mc )
399 for(y=0; y<b_h; y+=16){
404 s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst,
src + 3 + 3*
stride,
stride);
406 s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst ,
src + 3 + 3*
stride,
stride);
407 s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst+b_h,
src + 3 + b_h + 3*
stride,
stride);
410 s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst ,
src + 3 + 3*
stride ,
stride);
416 #define mca(dx,dy,b_w)\
417 static void mc_block_hpel ## dx ## dy ## b_w(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h){\
419 mc_block(NULL, dst, src-(HTAPS_MAX/2-1)-(HTAPS_MAX/2-1)*stride, stride, b_w, b_w, dx, dy);\
431 static
av_cold void snow_static_init(
void)
447 s->spatial_decomposition_count = 1;
456 s->qdsp.put_qpel_pixels_tab [0][dy+dx/4]=\
457 s->qdsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\
458 s->h264qpel.put_h264_qpel_pixels_tab[0][dy+dx/4];\
459 s->qdsp.put_qpel_pixels_tab [1][dy+dx/4]=\
460 s->qdsp.put_no_rnd_qpel_pixels_tab[1][dy+dx/4]=\
461 s->h264qpel.put_h264_qpel_pixels_tab[1][dy+dx/4];
481 s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\
482 s->hdsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\
483 mc_block_hpel ## dx ## dy ## 16;\
484 s->hdsp.put_pixels_tab [1][dy/4+dx/8]=\
485 s->hdsp.put_no_rnd_pixels_tab[1][dy/4+dx/8]=\
486 mc_block_hpel ## dx ## dy ## 8;
507 if (!
s->last_picture[
i])
513 if (!
s->mconly_picture || !
s->current_picture)
523 int plane_index,
level, orientation;
524 int ret, emu_buf_size;
536 if(
s->mconly_picture->format != avctx->
pix_fmt) {
541 for(plane_index=0; plane_index <
s->nb_planes; plane_index++){
542 int w=
s->avctx->width;
543 int h=
s->avctx->height;
549 s->plane[plane_index].width =
w;
550 s->plane[plane_index].height=
h;
553 for(orientation=
level ? 1 : 0; orientation<4; orientation++){
556 b->buf=
s->spatial_dwt_buffer;
558 b->stride=
s->plane[plane_index].width << (
s->spatial_decomposition_count -
level);
559 b->width = (
w + !(orientation&1))>>1;
560 b->height= (
h + !(orientation>1))>>1;
562 b->stride_line = 1 << (
s->spatial_decomposition_count -
level);
568 b->buf_x_offset = (
w+1)>>1;
571 b->buf +=
b->stride>>1;
572 b->buf_y_offset =
b->stride_line >> 1;
574 b->ibuf=
s->spatial_idwt_buffer + (
b->buf -
s->spatial_dwt_buffer);
577 b->parent= &
s->plane[plane_index].band[
level-1][orientation];
592 #define USE_HALFPEL_PLANE 0
597 for(p=0; p <
s->nb_planes; p++){
599 int w= is_chroma ?
AV_CEIL_RSHIFT(
s->avctx->width,
s->chroma_h_shift) :
s->avctx->width;
600 int h= is_chroma ?
AV_CEIL_RSHIFT(
s->avctx->height,
s->chroma_v_shift) :
s->avctx->height;
607 if (!halfpel[1][p] || !halfpel[2][p] || !halfpel[3][p]) {
651 if(
s->last_picture[
s->max_ref_frames-1]->data[0]){
654 if(
s->halfpel_plane[
s->max_ref_frames-1][1+
i/3][
i%3]) {
656 s->halfpel_plane[
s->max_ref_frames-1][1+
i/3][
i%3] =
NULL;
667 tmp=
s->last_picture[
s->max_ref_frames-1];
668 for(
i=
s->max_ref_frames-1;
i>0;
i--)
669 s->last_picture[
i] =
s->last_picture[
i-1];
670 memmove(
s->halfpel_plane+1,
s->halfpel_plane, (
s->max_ref_frames-1)*
sizeof(
void*)*4*4);
675 s->last_picture[0] =
s->current_picture;
676 s->current_picture =
tmp;
682 for(
i=0;
i<
s->max_ref_frames &&
s->last_picture[
i]->data[0];
i++)
683 if(
i &&
s->last_picture[
i-1]->key_frame)
686 if(
s->ref_frames==0){
694 s->current_picture->key_frame=
s->keyframe;
701 int plane_index,
level, orientation,
i;
722 if(
s->last_picture[
i] &&
s->last_picture[
i]->data[0]) {
723 av_assert0(
s->last_picture[
i]->data[0] !=
s->current_picture->data[0]);
728 for(plane_index=0; plane_index <
MAX_PLANES; plane_index++){
730 for(orientation=
level ? 1 : 0; orientation<4; orientation++){
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define AV_CEIL_RSHIFT(a, b)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define MAX_DECOMPOSITIONS
static float add(float src0, float src1)
int av_codec_is_encoder(const AVCodec *codec)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
static int weight(int i, int blen, int offset)
av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth)
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
common internal API header
#define FF_ALLOCZ_TYPED_ARRAY(p, nelem)
static int ff_thread_once(char *control, void(*routine)(void))
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx)
av_cold int ff_snow_common_init(AVCodecContext *avctx)
void ff_snow_pred_block(SnowContext *s, uint8_t *dst, uint8_t *tmp, ptrdiff_t stride, int sx, int sy, int b_w, int b_h, const BlockNode *block, int plane_index, int w, int h)
static void mc_block(Plane *p, uint8_t *dst, const uint8_t *src, int stride, int b_w, int b_h, int dx, int dy)
int ff_snow_get_buffer(SnowContext *s, AVFrame *frame)
static int halfpel_interpol(SnowContext *s, uint8_t *halfpel[4][4], AVFrame *frame)
void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_t **block, int b_w, int b_h, int src_x, int src_y, int src_stride, slice_buffer *sb, int add, uint8_t *dst8)
void ff_snow_release_buffer(AVCodecContext *avctx)
void ff_snow_reset_contexts(SnowContext *s)
int ff_snow_common_init_after_header(AVCodecContext *avctx)
int ff_snow_frame_start(SnowContext *s)
static av_cold void init_qexp(void)
#define USE_HALFPEL_PLANE
av_cold void ff_snow_common_end(SnowContext *s)
int ff_snow_alloc_blocks(SnowContext *s)
#define BLOCK_INTRA
Intra block, inter otherwise.
int ff_scale_mv_ref[MAX_REF_FRAMES][MAX_REF_FRAMES]
av_cold void ff_dwt_init(SnowDWTContext *c)
#define slice_buffer_get_line(slice_buf, line_num)
static const uint8_t obmc4[16]
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int flags
AV_CODEC_FLAG_*.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int8_t hcoeff[HTAPS_MAX/2]
Used to minimize the amount of memory used in order to optimize cache performance.
#define av_malloc_array(a, b)
static const uint8_t offset[127][2]