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]
52 +obmc4[x] * block[0][x + y*src_stride];
61 if(v&(~255)) v= ~(v>>31);
62 dst8[x + y*src_stride] = v;
84 for (i = 0; frame->
data[
i]; i++) {
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++){
130 for(i=0; i<
QROOT; i++){
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++){
190 int a_1=src[x + HTAPS_MAX/2-4];
191 int a0= src[x + HTAPS_MAX/2-3];
192 int a1= src[x + HTAPS_MAX/2-2];
193 int a2= src[x + HTAPS_MAX/2-1];
194 int a3= src[x + HTAPS_MAX/2+0];
195 int a4= src[x + HTAPS_MAX/2+1];
196 int a5= src[x + HTAPS_MAX/2+2];
197 int a6= src[x + HTAPS_MAX/2+3];
200 am= 20*(a2+
a3) - 5*(a1+a4) + (a0+
a5);
209 if(am&(~255)) am= ~(am>>31);
222 for(y=0; y < b_h; y++){
223 for(x=0; x < b_w+1; x++){
234 am= (20*(a2+
a3) - 5*(a1+a4) + (a0+
a5) + 16)>>5;
238 if(am&(~255)) am= ~(am>>31);
250 for(y=0; y < b_h; y++){
251 for(x=0; x < b_w; x++){
262 am= (20*(a2+
a3) - 5*(a1+a4) + (a0+
a5) + 512)>>10;
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++){
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)
396 mc_block(&s->
plane[plane_index], dst, src, stride, b_w, b_h, dx, dy);
399 for(y=0; y<b_h; y+=16){
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)
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; 523 int plane_index,
level, orientation;
524 int ret, emu_buf_size;
541 for(plane_index=0; plane_index < s->
nb_planes; plane_index++){
553 for(orientation=level ? 1 : 0; orientation<4; orientation++){
559 b->
width = (w + !(orientation&1))>>1;
560 b->
height= (h + !(orientation>1))>>1;
592 #define USE_HALFPEL_PLANE 0 607 if (!halfpel[1][p] || !halfpel[2][p] || !halfpel[3][p]) {
622 halfpel[1][p][
i]= (20*(src[
i] + src[i+1]) - 5*(src[i-1] + src[i+2]) + (src[i-2] + src[i+3]) + 16 )>>5;
629 halfpel[2][p][
i]= (20*(src[
i] + src[i+ls]) - 5*(src[i-ls] + src[i+2*ls]) + (src[i-2*ls] + src[i+3*ls]) + 16 )>>5;
637 halfpel[3][p][
i]= (20*(src[
i] + src[i+ls]) - 5*(src[i-ls] + src[i+2*ls]) + (src[i-2*ls] + src[i+3*ls]) + 16 )>>5;
701 int plane_index,
level, orientation,
i;
728 for(plane_index=0; plane_index <
MAX_PLANES; plane_index++){
730 for(orientation=level ? 1 : 0; orientation<4; orientation++){
uint8_t * scratchpad
data area for the ME algo, so that the ME does not need to malloc/free.
av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx)
av_cold int ff_snow_common_init(AVCodecContext *avctx)
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
const struct AVCodec * codec
int ff_snow_frame_start(SnowContext *s)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
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)
int av_codec_is_encoder(const AVCodec *codec)
#define BLOCK_INTRA
Intra block, inter otherwise.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
uint32_t * score_map
map to store the scores
static const uint8_t obmc4[16]
int ff_snow_common_init_after_header(AVCodecContext *avctx)
void ff_snow_reset_contexts(SnowContext *s)
void(* emulated_edge_mc)(uint8_t *dst, const uint8_t *src, ptrdiff_t dst_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
uint8_t ref
Reference frame index.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
av_cold void ff_dwt_init(SnowDWTContext *c)
The exact code depends on how similar the blocks are and how related they are to the block
int16_t mx
Motion vector component X, see mv_scale.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
uint32_t * ref_scores[MAX_REF_FRAMES]
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
int16_t my
Motion vector component Y, see mv_scale.
void ff_snow_release_buffer(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int16_t(*[MAX_REF_FRAMES] ref_mvs)[2]
SubBand band[DWT_LEVELS_3D][4]
static int halfpel_interpol(SnowContext *s, uint8_t *halfpel[4][4], AVFrame *frame)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int flags
AV_CODEC_FLAG_*.
qpel_mc_func put_h264_qpel_pixels_tab[4][16]
uint8_t * emu_edge_buffer
uint8_t color[3]
Color for intra.
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
#define USE_HALFPEL_PLANE
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)
static av_cold void init_qexp(void)
int width
picture width / height.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
uint8_t * halfpel_plane[MAX_REF_FRAMES][4][4]
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
uint8_t block_state[128+32 *128]
int ff_scale_mv_ref[MAX_REF_FRAMES][MAX_REF_FRAMES]
int ff_snow_get_buffer(SnowContext *s, AVFrame *frame)
Libavcodec external API header.
int spatial_decomposition_count
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
int8_t hcoeff[HTAPS_MAX/2]
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)
int ff_snow_alloc_blocks(SnowContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
DWTELEM * temp_dwt_buffer
static int weight(int i, int blen, int offset)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVFrame * current_picture
#define MAX_DECOMPOSITIONS
GLint GLenum GLboolean GLsizei stride
common internal api header.
IDWTELEM * temp_idwt_buffer
#define slice_buffer_get_line(slice_buf, line_num)
DWTELEM * spatial_dwt_buffer
uint32_t * map
map to avoid duplicate evaluations
IDWTELEM * spatial_idwt_buffer
uint8_t * obmc_scratchpad
static int ff_thread_once(char *control, void(*routine)(void))
int key_frame
1 -> keyframe, 0-> not
av_cold void ff_snow_common_end(SnowContext *s)
static float add(float src0, float src1)
#define av_malloc_array(a, b)
#define FF_ALLOCZ_TYPED_ARRAY(p, nelem)
uint8_t type
Bitfield of BLOCK_*.
Used to minimize the amount of memory used in order to optimize cache performance.
AVFrame * last_picture[MAX_REF_FRAMES]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
void * av_mallocz_array(size_t nmemb, size_t size)
#define AV_CEIL_RSHIFT(a, b)
int stride_line
Stride measured in lines, not pixels.