vf_mp.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Michael Niedermayer
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  * Parts of this file have been stolen from mplayer
21  */
22 
23 /**
24  * @file
25  */
26 
27 #include "avfilter.h"
28 #include "video.h"
29 #include "formats.h"
30 #include "internal.h"
31 #include "libavutil/avassert.h"
32 #include "libavutil/pixdesc.h"
33 #include "libavutil/intreadwrite.h"
34 #include "libavutil/imgutils.h"
35 #include "libavutil/opt.h"
36 
37 #include "libmpcodecs/vf.h"
38 #include "libmpcodecs/img_format.h"
39 #include "libmpcodecs/cpudetect.h"
40 #include "libmpcodecs/av_helpers.h"
41 #include "libmpcodecs/vf_scale.h"
43 
44 #include "libswscale/swscale.h"
45 
46 
47 //FIXME maybe link the orig in
48 //XXX: identical pix_fmt must be following with each others
49 static const struct {
50  int fmt;
52 } conversion_map[] = {
65  {IMGFMT_RGB1, AV_PIX_FMT_MONOBLACK},
87  {IMGFMT_Y8, AV_PIX_FMT_GRAY8},
89  {IMGFMT_IF09, AV_PIX_FMT_YUV410P},
91  {IMGFMT_I420, AV_PIX_FMT_YUV420P},
92  {IMGFMT_IYUV, AV_PIX_FMT_YUV420P},
97 
99 
106 
107  // YUVJ are YUV formats that use the full Y range and not just
108  // 16 - 235 (see colorspaces.txt).
109  // Currently they are all treated the same way.
114 
123  {0, AV_PIX_FMT_NONE}
124 };
125 
126 extern const vf_info_t ff_vf_info_dint;
127 extern const vf_info_t ff_vf_info_down3dright;
128 extern const vf_info_t ff_vf_info_eq2;
129 extern const vf_info_t ff_vf_info_eq;
130 extern const vf_info_t ff_vf_info_fil;
131 extern const vf_info_t ff_vf_info_fspp;
132 extern const vf_info_t ff_vf_info_ilpack;
133 extern const vf_info_t ff_vf_info_mcdeint;
134 extern const vf_info_t ff_vf_info_ow;
135 extern const vf_info_t ff_vf_info_perspective;
136 extern const vf_info_t ff_vf_info_phase;
137 extern const vf_info_t ff_vf_info_pp7;
138 extern const vf_info_t ff_vf_info_pullup;
139 extern const vf_info_t ff_vf_info_qp;
140 extern const vf_info_t ff_vf_info_sab;
142 extern const vf_info_t ff_vf_info_spp;
143 extern const vf_info_t ff_vf_info_tinterlace;
144 extern const vf_info_t ff_vf_info_uspp;
145 
146 
147 static const vf_info_t* const filters[]={
151  &ff_vf_info_eq,
156  &ff_vf_info_ow,
161  &ff_vf_info_qp,
167 
168  NULL
169 };
170 
171 /*
172 Unsupported filters
173 1bpp
174 ass
175 bmovl
176 crop
177 dvbscale
178 flip
179 expand
180 format
181 halfpack
182 lavc
183 lavcdeint
184 noformat
185 pp
186 scale
187 tfields
188 vo
189 yadif
190 zrmjpeg
191 */
192 
193 CpuCaps ff_gCpuCaps; //FIXME initialize this so optims work
194 
196  int i;
197  for(i=0; conversion_map[i].fmt && mp != conversion_map[i].fmt; i++)
198  ;
199  return mp == conversion_map[i].fmt ? conversion_map[i].pix_fmt : AV_PIX_FMT_NONE;
200 }
201 
202 static void ff_sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam)
203 {
204  static int firstTime=1;
205  *flags=0;
206 
207 #if ARCH_X86
208  if(ff_gCpuCaps.hasMMX)
209  __asm__ volatile("emms\n\t"::: "memory"); //FIXME this should not be required but it IS (even for non-MMX versions)
210 #endif
211  if(firstTime)
212  {
213  firstTime=0;
214  *flags= SWS_PRINT_INFO;
215  }
217 
218  switch(SWS_BILINEAR)
219  {
220  case 0: *flags|= SWS_FAST_BILINEAR; break;
221  case 1: *flags|= SWS_BILINEAR; break;
222  case 2: *flags|= SWS_BICUBIC; break;
223  case 3: *flags|= SWS_X; break;
224  case 4: *flags|= SWS_POINT; break;
225  case 5: *flags|= SWS_AREA; break;
226  case 6: *flags|= SWS_BICUBLIN; break;
227  case 7: *flags|= SWS_GAUSS; break;
228  case 8: *flags|= SWS_SINC; break;
229  case 9: *flags|= SWS_LANCZOS; break;
230  case 10:*flags|= SWS_SPLINE; break;
231  default:*flags|= SWS_BILINEAR; break;
232  }
233 
234  *srcFilterParam= NULL;
235  *dstFilterParam= NULL;
236 }
237 
238 //exact copy from vf_scale.c
239 // will use sws_flags & src_filter (from cmd line)
241 {
242  int flags, i;
243  SwsFilter *dstFilterParam, *srcFilterParam;
244  enum AVPixelFormat dfmt, sfmt;
245 
246  for(i=0; conversion_map[i].fmt && dstFormat != conversion_map[i].fmt; i++);
247  dfmt= conversion_map[i].pix_fmt;
248  for(i=0; conversion_map[i].fmt && srcFormat != conversion_map[i].fmt; i++);
249  sfmt= conversion_map[i].pix_fmt;
250 
251  if (srcFormat == IMGFMT_RGB8 || srcFormat == IMGFMT_BGR8) sfmt = AV_PIX_FMT_PAL8;
252  ff_sws_getFlagsAndFilterFromCmdLine(&flags, &srcFilterParam, &dstFilterParam);
253 
254  return sws_getContext(srcW, srcH, sfmt, dstW, dstH, dfmt, flags , srcFilterParam, dstFilterParam, NULL);
255 }
256 
257 typedef struct {
258  const AVClass *class;
263  char *filter;
264 } MPContext;
265 
266 #define OFFSET(x) offsetof(MPContext, x)
267 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
268 static const AVOption mp_options[] = {
269  { "filter", "set MPlayer filter name and parameters", OFFSET(filter), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
270  { NULL }
271 };
272 
274 
275 void ff_mp_msg(int mod, int lev, const char *format, ... ){
276  va_list va;
277  va_start(va, format);
278  //FIXME convert lev/mod
279  av_vlog(NULL, AV_LOG_DEBUG, format, va);
280  va_end(va);
281 }
282 
283 int ff_mp_msg_test(int mod, int lev){
284  return 123;
285 }
286 
287 void ff_init_avcodec(void)
288 {
289  //we maybe should init but its kinda 1. unneeded 2. a bit inpolite from here
290 }
291 
292 //Exact copy of vf.c
294  dst->pict_type= src->pict_type;
295  dst->fields = src->fields;
296  dst->qscale_type= src->qscale_type;
297  if(dst->width == src->width && dst->height == src->height){
298  dst->qstride= src->qstride;
299  dst->qscale= src->qscale;
300  }
301 }
302 
303 //Exact copy of vf.c
304 void ff_vf_next_draw_slice(struct vf_instance *vf,unsigned char** src, int * stride,int w, int h, int x, int y){
305  if (vf->next->draw_slice) {
306  vf->next->draw_slice(vf->next,src,stride,w,h,x,y);
307  return;
308  }
309  if (!vf->dmpi) {
310  ff_mp_msg(MSGT_VFILTER,MSGL_ERR,"draw_slice: dmpi not stored by vf_%s\n", vf->info->name);
311  return;
312  }
313  if (!(vf->dmpi->flags & MP_IMGFLAG_PLANAR)) {
314  memcpy_pic(vf->dmpi->planes[0]+y*vf->dmpi->stride[0]+vf->dmpi->bpp/8*x,
315  src[0], vf->dmpi->bpp/8*w, h, vf->dmpi->stride[0], stride[0]);
316  return;
317  }
318  memcpy_pic(vf->dmpi->planes[0]+y*vf->dmpi->stride[0]+x, src[0],
319  w, h, vf->dmpi->stride[0], stride[0]);
320  memcpy_pic(vf->dmpi->planes[1]+(y>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[1]+(x>>vf->dmpi->chroma_x_shift),
321  src[1], w>>vf->dmpi->chroma_x_shift, h>>vf->dmpi->chroma_y_shift, vf->dmpi->stride[1], stride[1]);
322  memcpy_pic(vf->dmpi->planes[2]+(y>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[2]+(x>>vf->dmpi->chroma_x_shift),
323  src[2], w>>vf->dmpi->chroma_x_shift, h>>vf->dmpi->chroma_y_shift, vf->dmpi->stride[2], stride[2]);
324 }
325 
326 //Exact copy of vf.c
327 void ff_vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h){
328  int y;
329  if(mpi->flags&MP_IMGFLAG_PLANAR){
330  y0&=~1;h+=h&1;
331  if(x0==0 && w==mpi->width){
332  // full width clear:
333  memset(mpi->planes[0]+mpi->stride[0]*y0,0,mpi->stride[0]*h);
334  memset(mpi->planes[1]+mpi->stride[1]*(y0>>mpi->chroma_y_shift),128,mpi->stride[1]*(h>>mpi->chroma_y_shift));
335  memset(mpi->planes[2]+mpi->stride[2]*(y0>>mpi->chroma_y_shift),128,mpi->stride[2]*(h>>mpi->chroma_y_shift));
336  } else
337  for(y=y0;y<y0+h;y+=2){
338  memset(mpi->planes[0]+x0+mpi->stride[0]*y,0,w);
339  memset(mpi->planes[0]+x0+mpi->stride[0]*(y+1),0,w);
340  memset(mpi->planes[1]+(x0>>mpi->chroma_x_shift)+mpi->stride[1]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift));
341  memset(mpi->planes[2]+(x0>>mpi->chroma_x_shift)+mpi->stride[2]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift));
342  }
343  return;
344  }
345  // packed:
346  for(y=y0;y<y0+h;y++){
347  unsigned char* dst=mpi->planes[0]+mpi->stride[0]*y+(mpi->bpp>>3)*x0;
348  if(mpi->flags&MP_IMGFLAG_YUV){
349  unsigned int* p=(unsigned int*) dst;
350  int size=(mpi->bpp>>3)*w/4;
351  int i;
352 #if HAVE_BIGENDIAN
353 #define CLEAR_PACKEDYUV_PATTERN 0x00800080
354 #define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x80008000
355 #else
356 #define CLEAR_PACKEDYUV_PATTERN 0x80008000
357 #define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x00800080
358 #endif
359  if(mpi->flags&MP_IMGFLAG_SWAPPED){
360  for(i=0;i<size-3;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=CLEAR_PACKEDYUV_PATTERN_SWAPPED;
361  for(;i<size;i++) p[i]=CLEAR_PACKEDYUV_PATTERN_SWAPPED;
362  } else {
363  for(i=0;i<size-3;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=CLEAR_PACKEDYUV_PATTERN;
364  for(;i<size;i++) p[i]=CLEAR_PACKEDYUV_PATTERN;
365  }
366  } else
367  memset(dst,0,(mpi->bpp>>3)*w);
368  }
369 }
370 
371 int ff_vf_next_query_format(struct vf_instance *vf, unsigned int fmt){
372  return 1;
373 }
374 
375 //used by delogo
376 unsigned int ff_vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned int preferred){
377  return preferred;
378 }
379 
380 mp_image_t* ff_vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){
381  MPContext *m= (MPContext*)(((uint8_t*)vf) - offsetof(MPContext, next_vf));
382  mp_image_t* mpi=NULL;
383  int w2;
384  int number = mp_imgtype >> 16;
385 
386  av_assert0(vf->next == NULL); // all existing filters call this just on next
387 
388  //vf_dint needs these as it calls ff_vf_get_image() before configuring the output
389  if(vf->w==0 && w>0) vf->w=w;
390  if(vf->h==0 && h>0) vf->h=h;
391 
392  av_assert0(w == -1 || w >= vf->w);
393  av_assert0(h == -1 || h >= vf->h);
394  av_assert0(vf->w > 0);
395  av_assert0(vf->h > 0);
396 
397  av_log(m->avfctx, AV_LOG_DEBUG, "get_image: %d:%d, vf: %d:%d\n", w,h,vf->w,vf->h);
398 
399  if (w == -1) w = vf->w;
400  if (h == -1) h = vf->h;
401 
402  w2=(mp_imgflag&MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE)?((w+15)&(~15)):w;
403 
404  // Note: we should call libvo first to check if it supports direct rendering
405  // and if not, then fallback to software buffers:
406  switch(mp_imgtype & 0xff){
407  case MP_IMGTYPE_EXPORT:
408  if(!vf->imgctx.export_images[0]) vf->imgctx.export_images[0]=ff_new_mp_image(w2,h);
409  mpi=vf->imgctx.export_images[0];
410  break;
411  case MP_IMGTYPE_STATIC:
412  if(!vf->imgctx.static_images[0]) vf->imgctx.static_images[0]=ff_new_mp_image(w2,h);
413  mpi=vf->imgctx.static_images[0];
414  break;
415  case MP_IMGTYPE_TEMP:
416  if(!vf->imgctx.temp_images[0]) vf->imgctx.temp_images[0]=ff_new_mp_image(w2,h);
417  mpi=vf->imgctx.temp_images[0];
418  break;
419  case MP_IMGTYPE_IPB:
420  if(!(mp_imgflag&MP_IMGFLAG_READABLE)){ // B frame:
421  if(!vf->imgctx.temp_images[0]) vf->imgctx.temp_images[0]=ff_new_mp_image(w2,h);
422  mpi=vf->imgctx.temp_images[0];
423  break;
424  }
425  case MP_IMGTYPE_IP:
427  mpi=vf->imgctx.static_images[vf->imgctx.static_idx];
428  vf->imgctx.static_idx^=1;
429  break;
430  case MP_IMGTYPE_NUMBERED:
431  if (number == -1) {
432  int i;
433  for (i = 0; i < NUM_NUMBERED_MPI; i++)
434  if (!vf->imgctx.numbered_images[i] || !vf->imgctx.numbered_images[i]->usage_count)
435  break;
436  number = i;
437  }
438  if (number < 0 || number >= NUM_NUMBERED_MPI) return NULL;
439  if (!vf->imgctx.numbered_images[number]) vf->imgctx.numbered_images[number] = ff_new_mp_image(w2,h);
440  mpi = vf->imgctx.numbered_images[number];
441  mpi->number = number;
442  break;
443  }
444  if(mpi){
445  mpi->type=mp_imgtype;
446  mpi->w=vf->w; mpi->h=vf->h;
447  // keep buffer allocation status & color flags only:
448 // mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT);
450  // accept restrictions, draw_slice and palette flags only:
452  if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
453  if(mpi->width!=w2 || mpi->height!=h){
454 // printf("vf.c: MPI parameters changed! %dx%d -> %dx%d \n", mpi->width,mpi->height,w2,h);
455  if(mpi->flags&MP_IMGFLAG_ALLOCATED){
456  if(mpi->width<w2 || mpi->height<h){
457  // need to re-allocate buffer memory:
458  av_free(mpi->planes[0]);
460  ff_mp_msg(MSGT_VFILTER,MSGL_V,"vf.c: have to REALLOCATE buffer memory :(\n");
461  }
462 // } else {
463  } {
464  mpi->width=w2; mpi->chroma_width=(w2 + (1<<mpi->chroma_x_shift) - 1)>>mpi->chroma_x_shift;
465  mpi->height=h; mpi->chroma_height=(h + (1<<mpi->chroma_y_shift) - 1)>>mpi->chroma_y_shift;
466  }
467  }
468  if(!mpi->bpp) ff_mp_image_setfmt(mpi,outfmt);
469  if(!(mpi->flags&MP_IMGFLAG_ALLOCATED) && mpi->type>MP_IMGTYPE_EXPORT){
470 
471  av_assert0(!vf->get_image);
472  // check libvo first!
473  if(vf->get_image) vf->get_image(vf,mpi);
474 
475  if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
476  // non-direct and not yet allocated image. allocate it!
477  if (!mpi->bpp) { // no way we can allocate this
479  "ff_vf_get_image: Tried to allocate a format that can not be allocated!\n");
480  return NULL;
481  }
482 
483  // check if codec prefer aligned stride:
484  if(mp_imgflag&MP_IMGFLAG_PREFER_ALIGNED_STRIDE){
485  int align=(mpi->flags&MP_IMGFLAG_PLANAR &&
486  mpi->flags&MP_IMGFLAG_YUV) ?
487  (8<<mpi->chroma_x_shift)-1 : 15; // -- maybe FIXME
488  w2=((w+align)&(~align));
489  if(mpi->width!=w2){
490 #if 0
491  // we have to change width... check if we CAN co it:
492  int flags=vf->query_format(vf,outfmt); // should not fail
493  if(!(flags&3)) ff_mp_msg(MSGT_DECVIDEO,MSGL_WARN,"??? ff_vf_get_image{vf->query_format(outfmt)} failed!\n");
494 // printf("query -> 0x%X \n",flags);
495  if(flags&VFCAP_ACCEPT_STRIDE){
496 #endif
497  mpi->width=w2;
498  mpi->chroma_width=(w2 + (1<<mpi->chroma_x_shift) - 1)>>mpi->chroma_x_shift;
499 // }
500  }
501  }
502 
504 // printf("clearing img!\n");
505  ff_vf_mpi_clear(mpi,0,0,mpi->width,mpi->height);
506  }
507  }
508  av_assert0(!vf->start_slice);
510  if(vf->start_slice) vf->start_slice(vf,mpi);
511  if(!(mpi->flags&MP_IMGFLAG_TYPE_DISPLAYED)){
512  ff_mp_msg(MSGT_DECVIDEO,MSGL_V,"*** [%s] %s%s mp_image_t, %dx%dx%dbpp %s %s, %d bytes\n",
513  "NULL"/*vf->info->name*/,
514  (mpi->type==MP_IMGTYPE_EXPORT)?"Exporting":
515  ((mpi->flags&MP_IMGFLAG_DIRECT)?"Direct Rendering":"Allocating"),
516  (mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)?" (slices)":"",
517  mpi->width,mpi->height,mpi->bpp,
518  (mpi->flags&MP_IMGFLAG_YUV)?"YUV":((mpi->flags&MP_IMGFLAG_SWAPPED)?"BGR":"RGB"),
519  (mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed",
520  mpi->bpp*mpi->width*mpi->height/8);
521  ff_mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"(imgfmt: %x, planes: %p,%p,%p strides: %d,%d,%d, chroma: %dx%d, shift: h:%d,v:%d)\n",
522  mpi->imgfmt, mpi->planes[0], mpi->planes[1], mpi->planes[2],
523  mpi->stride[0], mpi->stride[1], mpi->stride[2],
526  }
527 
528  mpi->qscale = NULL;
529  mpi->usage_count++;
530  }
531 // printf("\rVF_MPI: %p %p %p %d %d %d \n",
532 // mpi->planes[0],mpi->planes[1],mpi->planes[2],
533 // mpi->stride[0],mpi->stride[1],mpi->stride[2]);
534  return mpi;
535 }
536 
537 static void dummy_free(void *opaque, uint8_t *data){}
538 
539 int ff_vf_next_put_image(struct vf_instance *vf,mp_image_t *mpi, double pts){
540  MPContext *m= (MPContext*)(((uint8_t*)vf) - offsetof(MPContext, vf));
541  AVFilterLink *outlink = m->avfctx->outputs[0];
542  AVFrame *picref = av_frame_alloc();
543  int i;
544 
545  av_assert0(vf->next);
546 
547  av_log(m->avfctx, AV_LOG_DEBUG, "ff_vf_next_put_image\n");
548 
549  if (!picref)
550  goto fail;
551 
552  picref->width = mpi->w;
553  picref->height = mpi->h;
554 
555  picref->type = AVMEDIA_TYPE_VIDEO;
556 
557  for(i=0; conversion_map[i].fmt && mpi->imgfmt != conversion_map[i].fmt; i++);
558  picref->format = conversion_map[i].pix_fmt;
559 
560  memcpy(picref->linesize, mpi->stride, FFMIN(sizeof(picref->linesize), sizeof(mpi->stride)));
561 
562  for(i=0; i<4 && mpi->stride[i]; i++){
563  picref->data[i] = mpi->planes[i];
564  }
565 
566  if(pts != MP_NOPTS_VALUE)
567  picref->pts= pts * av_q2d(outlink->time_base);
568 
569  if(1) { // mp buffers are currently unsupported in libavfilter, we thus must copy
570  AVFrame *tofree = picref;
571  picref = av_frame_clone(picref);
572  av_frame_free(&tofree);
573  }
574 
575  ff_filter_frame(outlink, picref);
576  m->frame_returned++;
577 
578  return 1;
579 fail:
580  av_frame_free(&picref);
581  return 0;
582 }
583 
585  int width, int height, int d_width, int d_height,
586  unsigned int voflags, unsigned int outfmt){
587 
588  av_assert0(width>0 && height>0);
589  vf->next->w = width; vf->next->h = height;
590 
591  return 1;
592 #if 0
593  int flags=vf->next->query_format(vf->next,outfmt);
594  if(!flags){
595  // hmm. colorspace mismatch!!!
596  //this is fatal for us ATM
597  return 0;
598  }
599  ff_mp_msg(MSGT_VFILTER,MSGL_V,"REQ: flags=0x%X req=0x%X \n",flags,vf->default_reqs);
600  miss=vf->default_reqs - (flags&vf->default_reqs);
601  if(miss&VFCAP_ACCEPT_STRIDE){
602  // vf requires stride support but vf->next doesn't support it!
603  // let's insert the 'expand' filter, it does the job for us:
604  vf_instance_t* vf2=vf_open_filter(vf->next,"expand",NULL);
605  if(!vf2) return 0; // shouldn't happen!
606  vf->next=vf2;
607  }
608  vf->next->w = width; vf->next->h = height;
609  return 1;
610 #endif
611 }
612 
613 int ff_vf_next_control(struct vf_instance *vf, int request, void* data){
614  MPContext *m= (MPContext*)(((uint8_t*)vf) - offsetof(MPContext, vf));
615  av_log(m->avfctx, AV_LOG_DEBUG, "Received control %d\n", request);
616  return 0;
617 }
618 
619 static int vf_default_query_format(struct vf_instance *vf, unsigned int fmt){
620  MPContext *m= (MPContext*)(((uint8_t*)vf) - offsetof(MPContext, vf));
621  int i;
622  av_log(m->avfctx, AV_LOG_DEBUG, "query %X\n", fmt);
623 
624  for(i=0; conversion_map[i].fmt; i++){
625  if(fmt==conversion_map[i].fmt)
626  return 1; //we suport all
627  }
628  return 0;
629 }
630 
631 
632 static av_cold int init(AVFilterContext *ctx)
633 {
634  MPContext *m = ctx->priv;
635  int cpu_flags = av_get_cpu_flags();
636  char name[256];
637  const char *args;
638  int i;
639 
640  ff_gCpuCaps.hasMMX = cpu_flags & AV_CPU_FLAG_MMX;
641  ff_gCpuCaps.hasMMX2 = cpu_flags & AV_CPU_FLAG_MMX2;
642  ff_gCpuCaps.hasSSE = cpu_flags & AV_CPU_FLAG_SSE;
643  ff_gCpuCaps.hasSSE2 = cpu_flags & AV_CPU_FLAG_SSE2;
644  ff_gCpuCaps.hasSSE3 = cpu_flags & AV_CPU_FLAG_SSE3;
645  ff_gCpuCaps.hasSSSE3 = cpu_flags & AV_CPU_FLAG_SSSE3;
646  ff_gCpuCaps.hasSSE4 = cpu_flags & AV_CPU_FLAG_SSE4;
647  ff_gCpuCaps.hasSSE42 = cpu_flags & AV_CPU_FLAG_SSE42;
648  ff_gCpuCaps.hasAVX = cpu_flags & AV_CPU_FLAG_AVX;
649  ff_gCpuCaps.has3DNow = cpu_flags & AV_CPU_FLAG_3DNOW;
650  ff_gCpuCaps.has3DNowExt = cpu_flags & AV_CPU_FLAG_3DNOWEXT;
651 
652  m->avfctx= ctx;
653 
654  args = m->filter;
655  if(!args || 1!=sscanf(args, "%255[^:=]", name)){
656  av_log(ctx, AV_LOG_ERROR, "Invalid parameter.\n");
657  return AVERROR(EINVAL);
658  }
659  args += strlen(name);
660  if (args[0] == '=')
661  args++;
662 
663  for(i=0; ;i++){
664  if(!filters[i] || !strcmp(name, filters[i]->name))
665  break;
666  }
667 
668  if(!filters[i]){
669  av_log(ctx, AV_LOG_ERROR, "Unknown filter %s\n", name);
670  return AVERROR(EINVAL);
671  }
672 
673  av_log(ctx, AV_LOG_WARNING,
674  "'%s' is a wrapped MPlayer filter (libmpcodecs). This filter may be removed\n"
675  "once it has been ported to a native libavfilter.\n", name);
676 
677  memset(&m->vf,0,sizeof(m->vf));
678  m->vf.info= filters[i];
679 
680  m->vf.next = &m->next_vf;
686  m->vf.default_reqs=0;
687  if(m->vf.info->opts)
688  av_log(ctx, AV_LOG_ERROR, "opts / m_struct_set is unsupported\n");
689 #if 0
690  if(vf->info->opts) { // vf_vo get some special argument
691  const m_struct_t* st = vf->info->opts;
692  void* vf_priv = m_struct_alloc(st);
693  int n;
694  for(n = 0 ; args && args[2*n] ; n++)
695  m_struct_set(st,vf_priv,args[2*n],args[2*n+1]);
696  vf->priv = vf_priv;
697  args = NULL;
698  } else // Otherwise we should have the '_oldargs_'
699  if(args && !strcmp(args[0],"_oldargs_"))
700  args = (char**)args[1];
701  else
702  args = NULL;
703 #endif
704  if(m->vf.info->vf_open(&m->vf, (char*)args)<=0){
705  av_log(ctx, AV_LOG_ERROR, "vf_open() of %s with arg=%s failed\n", name, args);
706  return -1;
707  }
708 
709  return 0;
710 }
711 
712 static av_cold void uninit(AVFilterContext *ctx)
713 {
714  MPContext *m = ctx->priv;
715  vf_instance_t *vf = &m->vf;
716 
717  while(vf){
718  vf_instance_t *next = vf->next;
719  if(vf->uninit)
720  vf->uninit(vf);
725  vf = next;
726  }
727 }
728 
730 {
731  AVFilterFormats *avfmts=NULL;
732  MPContext *m = ctx->priv;
733  enum AVPixelFormat lastpixfmt = AV_PIX_FMT_NONE;
734  int i;
735 
736  for(i=0; conversion_map[i].fmt; i++){
737  av_log(ctx, AV_LOG_DEBUG, "query: %X\n", conversion_map[i].fmt);
738  if(m->vf.query_format(&m->vf, conversion_map[i].fmt)){
739  av_log(ctx, AV_LOG_DEBUG, "supported,adding\n");
740  if (conversion_map[i].pix_fmt != lastpixfmt) {
741  ff_add_format(&avfmts, conversion_map[i].pix_fmt);
742  lastpixfmt = conversion_map[i].pix_fmt;
743  }
744  }
745  }
746 
747  if (!avfmts)
748  return -1;
749 
750  //We assume all allowed input formats are also allowed output formats
751  ff_set_common_formats(ctx, avfmts);
752  return 0;
753 }
754 
755 static int config_inprops(AVFilterLink *inlink)
756 {
757  MPContext *m = inlink->dst->priv;
758  int i;
759  for(i=0; conversion_map[i].fmt && conversion_map[i].pix_fmt != inlink->format; i++);
760 
761  av_assert0(conversion_map[i].fmt && inlink->w && inlink->h);
762 
763  m->vf.fmt.have_configured = 1;
764  m->vf.fmt.orig_height = inlink->h;
765  m->vf.fmt.orig_width = inlink->w;
766  m->vf.fmt.orig_fmt = conversion_map[i].fmt;
767 
768  if(m->vf.config(&m->vf, inlink->w, inlink->h, inlink->w, inlink->h, 0, conversion_map[i].fmt)<=0)
769  return -1;
770 
771  return 0;
772 }
773 
774 static int config_outprops(AVFilterLink *outlink)
775 {
776  MPContext *m = outlink->src->priv;
777 
778  outlink->w = m->next_vf.w;
779  outlink->h = m->next_vf.h;
780 
781  return 0;
782 }
783 
784 static int request_frame(AVFilterLink *outlink)
785 {
786  MPContext *m = outlink->src->priv;
787  int ret;
788 
789  av_log(m->avfctx, AV_LOG_DEBUG, "mp request_frame\n");
790 
791  for(m->frame_returned=0; !m->frame_returned;){
792  ret=ff_request_frame(outlink->src->inputs[0]);
793  if(ret<0)
794  break;
795  }
796 
797  av_log(m->avfctx, AV_LOG_DEBUG, "mp request_frame ret=%d\n", ret);
798  return ret;
799 }
800 
801 static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
802 {
803  MPContext *m = inlink->dst->priv;
804  int i;
805  double pts= MP_NOPTS_VALUE;
806  mp_image_t* mpi = ff_new_mp_image(inpic->width, inpic->height);
807 
808  if(inpic->pts != AV_NOPTS_VALUE)
809  pts= inpic->pts / av_q2d(inlink->time_base);
810 
811  for(i=0; conversion_map[i].fmt && conversion_map[i].pix_fmt != inlink->format; i++);
813 
814  memcpy(mpi->planes, inpic->data, FFMIN(sizeof(inpic->data) , sizeof(mpi->planes)));
815  memcpy(mpi->stride, inpic->linesize, FFMIN(sizeof(inpic->linesize), sizeof(mpi->stride)));
816 
817  //FIXME pass interleced & tff flags around
818 
819  // mpi->flags|=MP_IMGFLAG_ALLOCATED; ?
820  mpi->flags |= MP_IMGFLAG_READABLE;
821  if(!av_frame_is_writable(inpic))
822  mpi->flags |= MP_IMGFLAG_PRESERVE;
823  if(m->vf.put_image(&m->vf, mpi, pts) == 0){
824  av_log(m->avfctx, AV_LOG_DEBUG, "put_image() says skip\n");
825  }else{
826  av_frame_free(&inpic);
827  }
828  ff_free_mp_image(mpi);
829  return 0;
830 }
831 
832 static const AVFilterPad mp_inputs[] = {
833  {
834  .name = "default",
835  .type = AVMEDIA_TYPE_VIDEO,
836  .filter_frame = filter_frame,
837  .config_props = config_inprops,
838  },
839  { NULL }
840 };
841 
842 static const AVFilterPad mp_outputs[] = {
843  {
844  .name = "default",
845  .type = AVMEDIA_TYPE_VIDEO,
846  .request_frame = request_frame,
847  .config_props = config_outprops,
848  },
849  { NULL }
850 };
851 
853  .name = "mp",
854  .description = NULL_IF_CONFIG_SMALL("Apply a libmpcodecs filter to the input video."),
855  .init = init,
856  .uninit = uninit,
857  .priv_size = sizeof(MPContext),
859  .inputs = mp_inputs,
860  .outputs = mp_outputs,
861  .priv_class = &mp_class,
862 };
const char * name
Definition: avisynth_c.h:675
#define MSGL_FATAL
Definition: mp_msg.h:32
#define IMGFMT_YUY2
Definition: img_format.h:240
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:85
void ff_mp_msg(int mod, int lev, const char *format,...)
Definition: vf_mp.c:275
#define IMGFMT_444P16_LE
Definition: img_format.h:146
#define AV_CPU_FLAG_AVX
AVX functions: requires OS support even if YMM registers aren&#39;t used.
Definition: cpu.h:43
#define IMGFMT_XVMC_MOCO_MPEG2
Definition: img_format.h:267
unsigned int imgfmt
Definition: mp_image.h:130
#define IMGFMT_RGB4
Definition: img_format.h:29
#define SWS_POINT
Definition: swscale.h:62
const vf_info_t ff_vf_info_qp
Definition: vf_qp.c:171
#define IMGFMT_RGB15BE
Definition: img_format.h:90
int ff_mp_msg_test(int mod, int lev)
Definition: vf_mp.c:283
This structure describes decoded (raw) audio or video data.
Definition: frame.h:76
void(* get_image)(struct vf_instance *vf, mp_image_t *mpi)
Definition: vf.h:66
#define MSGL_ERR
Definition: mp_msg.h:33
AVOption.
Definition: opt.h:251
int qscale_type
Definition: mp_image.h:139
char * qscale
Definition: mp_image.h:135
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:73
misc image utilities
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
void ff_init_avcodec(void)
Definition: vf_mp.c:287
MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstr...
Definition: pixfmt.h:108
#define IMGFMT_422P16_LE
Definition: img_format.h:156
external API header
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:70
int(* control)(struct vf_instance *vf, int request, void *data)
Definition: vf.h:62
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
Definition: pixfmt.h:88
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:154
const char * name
Definition: vf.h:33
#define IMGFMT_RGB48LE
Definition: img_format.h:37
#define AV_CPU_FLAG_SSE
SSE functions.
Definition: cpu.h:33
const vf_info_t ff_vf_info_softpulldown
int ff_vf_next_query_format(struct vf_instance *vf, unsigned int fmt)
Definition: vf_mp.c:371
#define IMGFMT_RGB15LE
Definition: img_format.h:91
#define NUM_NUMBERED_MPI
Definition: vf.h:41
int fields
Definition: mp_image.h:138
mp_image_t * ff_vf_get_image(vf_instance_t *vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h)
Definition: vf_mp.c:380
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
Definition: pixfmt.h:117
#define IMGFMT_RGBA
Definition: img_format.h:85
static const AVOption mp_options[]
Definition: vf_mp.c:268
#define SWS_FAST_BILINEAR
Definition: swscale.h:58
#define SWS_BICUBIC
Definition: swscale.h:60
const vf_info_t ff_vf_info_phase
Definition: vf_phase.c:295
#define AV_CPU_FLAG_MMX2
SSE integer functions or AMD MMX ext.
Definition: cpu.h:31
int hasSSSE3
Definition: cpudetect.h:40
#define IMGFMT_RGB12BE
Definition: img_format.h:88
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
Definition: pixfmt.h:120
#define IMGFMT_NV12
Definition: img_format.h:125
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 ...
Definition: pixfmt.h:138
#define MP_IMGFLAG_PRESERVE
Definition: mp_image.h:46
static void ff_sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam)
Definition: vf_mp.c:202
#define IMGFMT_BGR24
Definition: img_format.h:51
static void dummy_free(void *opaque, uint8_t *data)
Definition: vf_mp.c:537
#define IMGFMT_YVU9
Definition: img_format.h:117
struct SwsContext * sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Allocate and return an SwsContext.
const vf_info_t ff_vf_info_eq
Definition: vf_eq.c:234
#define MP_IMGTYPE_EXPORT
Definition: mp_image.h:100
#define MSGL_V
Definition: mp_msg.h:38
#define IMGFMT_UYVY
Definition: img_format.h:236
#define IMGFMT_YV12
Definition: img_format.h:119
#define SWS_SPLINE
Definition: swscale.h:68
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer 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 list
int stride
Definition: mace.c:144
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:128
void(* uninit)(struct vf_instance *vf)
Definition: vf.h:74
#define MP_IMGFLAG_READABLE
Definition: mp_image.h:55
static int request_frame(AVFilterLink *outlink)
Definition: vf_mp.c:784
#define IMGFMT_Y8
Definition: img_format.h:124
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
Definition: pixfmt.h:91
output residual component w
#define SWS_SINC
Definition: swscale.h:66
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:115
int srcH
Height of source luma/alpha planes.
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
Definition: pixfmt.h:89
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:532
int width
Definition: mp_image.h:131
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
void(* draw_slice)(struct vf_instance *vf, unsigned char **src, int *stride, int w, int h, int x, int y)
Definition: vf.h:72
int has3DNow
Definition: cpudetect.h:35
const void * opts
Definition: vf.h:38
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:105
int(* put_image)(struct vf_instance *vf, mp_image_t *mpi, double pts)
Definition: vf.h:68
uint8_t
#define MP_IMGFLAG_YUV
Definition: mp_image.h:78
it can be given away to ff_start_frame *A reference passed to ff_filter_frame(or the deprecated ff_start_frame) is given away and must no longer be used.*A reference created with avfilter_ref_buffer belongs to the code that created it.*A reference obtained with ff_get_video_buffer or ff_get_audio_buffer belongs to the code that requested it.*A reference given as return value by the get_video_buffer or get_audio_buffer method is given away and must no longer be used.Link reference fields---------------------The AVFilterLink structure has a few AVFilterBufferRef fields.The cur_buf and out_buf were used with the deprecated start_frame/draw_slice/end_frame API and should no longer be used.src_buf
#define av_cold
Definition: attributes.h:78
#define IMGFMT_XVMC_IDCT_MPEG2
Definition: img_format.h:268
8 bit with PIX_FMT_RGB32 palette
Definition: pixfmt.h:79
AVOptions.
window constants for m
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
Definition: pixfmt.h:112
#define IMGFMT_444P16_BE
Definition: img_format.h:147
Definition: vf.h:31
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 ...
Definition: pixfmt.h:137
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:159
static int config_inprops(AVFilterLink *inlink)
Definition: vf_mp.c:755
unsigned char * planes[MP_MAX_PLANES]
Definition: mp_image.h:133
#define IMGFMT_BGR12LE
Definition: img_format.h:95
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
Definition: pixfmt.h:114
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:98
#define IMGFMT_ARGB
Definition: img_format.h:84
the mask is usually to keep the same permissions Filters should remove permissions on reference they give to output whenever necessary It can be automatically done by setting the rej_perms field on the output pad Here are a few guidelines corresponding to common then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
const vf_info_t ff_vf_info_uspp
Definition: vf_uspp.c:386
int stride[MP_MAX_PLANES]
Definition: mp_image.h:134
static double av_q2d(AVRational a)
Convert rational to double.
Definition: rational.h:69
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
Definition: pixfmt.h:104
AVFilterContext * avfctx
Definition: vf_mp.c:261
const vf_info_t ff_vf_info_ilpack
Definition: vf_ilpack.c:451
void ff_vf_mpi_clear(mp_image_t *mpi, int x0, int y0, int w, int h)
Definition: vf_mp.c:327
#define IMGFMT_BG4B
Definition: img_format.h:106
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
Definition: pixfmt.h:81
#define SWS_BICUBLIN
Definition: swscale.h:64
MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstr...
Definition: pixfmt.h:107
int pict_type
Definition: mp_image.h:137
const vf_info_t ff_vf_info_perspective
WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstrea...
Definition: pixfmt.h:109
int orig_height
Definition: vf.h:53
void ff_mp_image_setfmt(mp_image_t *mpi, unsigned int out_fmt)
Definition: mp_image.c:105
external API header
enum AVPixelFormat dstFormat
Destination pixel format.
void ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:545
void ff_free_mp_image(mp_image_t *mpi)
Definition: mp_image.c:243
int hasSSE4
Definition: cpudetect.h:41
#define IMGFMT_IF09
Definition: img_format.h:118
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
Definition: vf_mp.c:801
int ff_vf_next_config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int voflags, unsigned int outfmt)
Definition: vf_mp.c:584
static const vf_info_t *const filters[]
Definition: vf_mp.c:147
const vf_info_t ff_vf_info_mcdeint
Definition: vf_mcdeint.c:333
int qstride
Definition: mp_image.h:136
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Definition: log.c:258
A filter pad used for either input or output.
int dstH
Height of destination luma/alpha planes.
Discrete Time axis x
mp_image_t * temp_images[1]
Definition: vf.h:45
int hasMMX2
Definition: cpudetect.h:34
#define AV_CPU_FLAG_SSE42
Nehalem SSE4.2 functions.
Definition: cpu.h:42
const vf_info_t ff_vf_info_tinterlace
int chroma_height
Definition: mp_image.h:143
int width
width and height of the video frame
Definition: frame.h:122
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
Definition: mem.c:183
#define IMGFMT_RGB48BE
Definition: img_format.h:38
#define AV_CPU_FLAG_SSSE3
Conroe SSSE3 functions.
Definition: cpu.h:39
#define MP_IMGTYPE_TEMP
Definition: mp_image.h:104
int(* query_format)(struct vf_instance *vf, unsigned int fmt)
Definition: vf.h:64
static const struct @124 conversion_map[]
#define MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE
Definition: mp_image.h:59
int orig_fmt
Definition: vf.h:53
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:133
const vf_info_t ff_vf_info_spp
Definition: vf_spp.c:614
#define IMGFMT_422P16_BE
Definition: img_format.h:157
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define MP_IMGTYPE_STATIC
Definition: mp_image.h:102
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:99
Spectrum Plot time data
void * priv
private data for use by the filter
Definition: avfilter.h:545
static int vf_default_query_format(struct vf_instance *vf, unsigned int fmt)
Definition: vf_mp.c:619
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:361
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:93
#define IMGFMT_IYUV
Definition: img_format.h:121
simple assert() macros that are a bit more flexible than ISO C assert().
#define IMGFMT_NV21
Definition: img_format.h:126
#define IMGFMT_RGB12LE
Definition: img_format.h:89
XVideo Motion Acceleration via common packet passing.
Definition: pixfmt.h:83
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
int ff_add_format(AVFilterFormats **avff, int64_t fmt)
Add fmt to the list of media formats contained in *avff.
Definition: formats.c:344
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:131
#define SWS_X
Definition: swscale.h:61
#define CLEAR_PACKEDYUV_PATTERN_SWAPPED
#define CLEAR_PACKEDYUV_PATTERN
char * filter
Definition: vf_mp.c:263
#define MSGT_VFILTER
Definition: mp_msg.h:94
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:96
int size
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:97
#define IMGFMT_BGR16LE
Definition: img_format.h:99
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:72
as above, but U and V bytes are swapped
Definition: pixfmt.h:94
#define MP_IMGFLAG_PREFER_ALIGNED_STRIDE
Definition: mp_image.h:61
#define MP_IMGFLAG_DRAW_CALLBACK
Definition: mp_image.h:89
#define FFMIN(a, b)
Definition: common.h:58
int fmt
Definition: vf_mp.c:50
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
Definition: pixfmt.h:92
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
Definition: pixfmt.h:80
#define AV_CPU_FLAG_SSE3
Prescott SSE3 functions.
Definition: cpu.h:37
ret
Definition: avfilter.c:821
#define MSGL_DBG2
Definition: mp_msg.h:39
void(* start_slice)(struct vf_instance *vf, mp_image_t *mpi)
Definition: vf.h:70
CpuCaps ff_gCpuCaps
Definition: vf_mp.c:193
int hasAVX
Definition: cpudetect.h:44
AVS_Value args
Definition: avisynth_c.h:603
#define MP_IMGFLAGMASK_COLORS
Definition: mp_image.h:84
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer 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 format(the sample packing is implied by the sample format) and sample rate.The lists are not just lists
unsigned int default_reqs
Definition: vf.h:79
int number
Definition: mp_image.h:128
vf_instance_t next_vf
Definition: vf_mp.c:260
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:71
int hasSSE42
Definition: cpudetect.h:42
unsigned char bpp
Definition: mp_image.h:129
int chroma_y_shift
Definition: mp_image.h:145
#define IMGFMT_VDPAU_MPEG1
Definition: img_format.h:274
int hasMMX
Definition: cpudetect.h:33
static int cpu_flags
Definition: dct-test.c:77
int dstW
Width of destination luma/alpha planes.
const vf_info_t ff_vf_info_down3dright
struct vf_instance * next
Definition: vf.h:84
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
Definition: pixfmt.h:119
const vf_info_t ff_vf_info_fspp
Definition: vf_fspp.c:683
void ff_mp_image_alloc_planes(mp_image_t *mpi)
Definition: mp_image.c:36
static const AVFilterPad mp_outputs[]
Definition: vf_mp.c:842
vf_format_context_t fmt
Definition: vf.h:83
#define AV_CPU_FLAG_3DNOW
AMD 3DNOW.
Definition: cpu.h:32
AVFrame * av_frame_clone(AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:317
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:134
const AVS_VideoInfo int align
Definition: avisynth_c.h:695
#define IMGFMT_BGR12BE
Definition: img_format.h:94
#define MP_IMGFLAG_RGB_PALETTE
Definition: mp_image.h:82
#define IMGFMT_440P
Definition: img_format.h:133
int has3DNowExt
Definition: cpudetect.h:36
NULL
Definition: eval.c:55
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:87
static int width
Definition: tests/utils.c:158
const vf_info_t ff_vf_info_sab
Definition: vf_sab.c:315
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:129
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_mp.c:712
AVS_Value src
Definition: avisynth_c.h:523
enum AVPixelFormat ff_mp2ff_pix_fmt(int mp)
Definition: vf_mp.c:195
const vf_info_t ff_vf_info_dint
Definition: vf_dint.c:207
int static_idx
Definition: vf.h:48
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:101
#define SWS_GAUSS
Definition: swscale.h:65
#define AV_CPU_FLAG_MMX
standard MMX
Definition: cpu.h:29
vf_instance_t vf
Definition: vf_mp.c:259
#define IMGFMT_420P16_LE
Definition: img_format.h:166
#define IMGFMT_VDPAU_H264
Definition: img_format.h:276
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:69
#define memcpy_pic(d, s, b, h, ds, ss)
Definition: fastmemcpy.h:62
#define IMGFMT_RG4B
Definition: img_format.h:105
unsigned int default_caps
Definition: vf.h:78
MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstre...
Definition: pixfmt.h:134
int orig_width
Definition: vf.h:53
H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstre...
Definition: pixfmt.h:106
struct SwsContext * ff_sws_getContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat)
Definition: vf_mp.c:240
BYTE int const BYTE int int int height
Definition: avisynth_c.h:713
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:74
Describe the class of an AVClass context structure.
Definition: log.h:50
int usage_count
Definition: mp_image.h:146
Filter definition.
Definition: avfilter.h:436
int hasSSE
Definition: cpudetect.h:37
synthesis window for stochastic i
int chroma_width
Definition: mp_image.h:142
#define MP_IMGFLAG_ALLOCATED
Definition: mp_image.h:93
unsigned int ff_vf_match_csp(vf_instance_t **vfp, const unsigned int *list, unsigned int preferred)
Definition: vf_mp.c:376
#define AV_CPU_FLAG_SSE4
Penryn SSE4.1 functions.
Definition: cpu.h:41
AVFilter avfilter_vf_mp
Definition: vf_mp.c:852
#define IMGFMT_Y800
Definition: img_format.h:123
int(* vf_open)(struct vf_instance *vf, char *args)
Definition: vf.h:36
#define IMGFMT_RGB1
Definition: img_format.h:28
#define IMGFMT_422P
Definition: img_format.h:131
const char * name
filter name
Definition: avfilter.h:437
#define IMGFMT_BGR16BE
Definition: img_format.h:98
const vf_info_t * info
Definition: vf.h:57
int w
Definition: mp_image.h:132
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 ...
Definition: pixfmt.h:122
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:30
int(* config)(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt)
Definition: vf.h:59
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer 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.Buffer references ownership and permissions
const vf_info_t ff_vf_info_pp7
Definition: vf_pp7.c:484
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:539
int w
Definition: vf.h:81
#define IMGFMT_BGR15LE
Definition: img_format.h:97
#define IMGFMT_RGB16BE
Definition: img_format.h:92
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:95
#define IMGFMT_420P16_BE
Definition: img_format.h:167
#define IMGFMT_ABGR
Definition: img_format.h:82
const vf_info_t ff_vf_info_ow
Definition: vf_ow.c:315
const vf_info_t ff_vf_info_pullup
Definition: vf_pullup.c:309
static int flags
Definition: cpu.c:23
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
Definition: pixfmt.h:116
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:87
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 ...
Definition: pixfmt.h:140
#define IMGFMT_BGR4
Definition: img_format.h:45
#define AV_CPU_FLAG_3DNOWEXT
AMD 3DNowExt.
Definition: cpu.h:36
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:132
vf_instance_t * vf_open_filter(vf_instance_t *next, const char *name, char **args)
int height
Definition: mp_image.h:131
void ff_vf_clone_mpi_attributes(mp_image_t *dst, mp_image_t *src)
Definition: vf_mp.c:293
unsigned char type
Definition: mp_image.h:127
VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstrea...
Definition: pixfmt.h:110
#define IMGFMT_BGR8
Definition: img_format.h:47
#define IMGFMT_444P
Definition: img_format.h:130
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:78
#define MP_IMGFLAGMASK_RESTRICTIONS
Definition: mp_image.h:72
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:68
Y , 8bpp.
Definition: pixfmt.h:76
#define MSGL_WARN
Definition: mp_msg.h:34
mp_image_t * export_images[1]
Definition: vf.h:46
static av_cold int init(AVFilterContext *ctx)
Definition: vf_mp.c:632
#define IMGFMT_RGB24
Definition: img_format.h:35
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:162
int ff_vf_next_control(struct vf_instance *vf, int request, void *data)
Definition: vf_mp.c:613
#define MP_IMGFLAG_PLANAR
Definition: mp_image.h:76
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:108
#define IMGFMT_BGRA
Definition: img_format.h:83
#define FLAGS
Definition: vf_mp.c:267
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
Definition: pixfmt.h:111
const vf_info_t ff_vf_info_eq2
Definition: vf_eq2.c:512
enum AVPixelFormat srcFormat
Source pixel format.
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:130
#define SWS_BILINEAR
Definition: swscale.h:59
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
Definition: pixfmt.h:82
int frame_returned
Definition: vf_mp.c:262
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
Definition: pixfmt.h:90
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:75
void ff_vf_next_draw_slice(struct vf_instance *vf, unsigned char **src, int *stride, int w, int h, int x, int y)
Definition: vf_mp.c:304
#define IMGFMT_VDPAU_VC1
Definition: img_format.h:278
function y
Definition: D.m:1
#define IMGFMT_BGR1
Definition: img_format.h:44
#define SWS_AREA
Definition: swscale.h:63
int hasSSE2
Definition: cpudetect.h:38
vf_image_context_t imgctx
Definition: vf.h:82
static int query_formats(AVFilterContext *ctx)
Definition: vf_mp.c:729
mp_image_t * static_images[2]
Definition: vf.h:44
int ff_vf_next_put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
Definition: vf_mp.c:539
#define MP_IMGTYPE_NUMBERED
Definition: mp_image.h:110
AVFILTER_DEFINE_CLASS(mp)
static int config_outprops(AVFilterLink *outlink)
Definition: vf_mp.c:774
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
#define SWS_LANCZOS
Definition: swscale.h:67
#define IMGFMT_VDPAU_WMV3
Definition: img_format.h:277
int have_configured
Definition: vf.h:52
int chroma_x_shift
Definition: mp_image.h:144
mp_image_t * numbered_images[NUM_NUMBERED_MPI]
Definition: vf.h:47
A list of supported formats for one end of a filter link.
Definition: formats.h:64
enum AVPixelFormat pix_fmt
Definition: vf_mp.c:51
#define IMGFMT_RGB16LE
Definition: img_format.h:93
#define IMGFMT_RGB8
Definition: img_format.h:31
mp_image_t * ff_new_mp_image(int w, int h)
Definition: mp_image.c:234
#define IMGFMT_420A
Definition: img_format.h:140
An instance of a filter.
Definition: avfilter.h:524
int hasSSE3
Definition: cpudetect.h:39
struct vf_priv_s * priv
Definition: vf.h:86
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 ...
Definition: pixfmt.h:121
#define MP_IMGFLAG_TYPE_DISPLAYED
Definition: mp_image.h:96
static const AVFilterPad mp_inputs[]
Definition: vf_mp.c:832
int height
Definition: frame.h:122
#define AV_CPU_FLAG_SSE2
PIV SSE2 functions.
Definition: cpu.h:34
#define IMGFMT_VDPAU_MPEG2
Definition: img_format.h:275
#define IMGFMT_VDPAU_MPEG4
Definition: img_format.h:279
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:103
#define MSGT_DECVIDEO
Definition: mp_msg.h:67
#define MP_IMGFLAG_DIRECT
Definition: mp_image.h:91
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 ...
Definition: pixfmt.h:139
int h
Definition: vf.h:81
#define IMGFMT_I420
Definition: img_format.h:120
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:319
int h
Definition: mp_image.h:132
#define MP_IMGTYPE_IPB
Definition: mp_image.h:108
internal API functions
attribute_deprecated int type
Definition: frame.h:258
int srcW
Width of source luma/alpha planes.
int flags
Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
AVPixelFormat
Pixel format.
Definition: pixfmt.h:66
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 inputs
#define MP_IMGFLAG_SWAPPED
Definition: mp_image.h:80
#define SWS_PRINT_INFO
Definition: swscale.h:75
const vf_info_t ff_vf_info_fil
Definition: vf_fil.c:107
#define VFCAP_ACCEPT_STRIDE
Definition: vfcap.h:44
#define OFFSET(x)
Definition: vf_mp.c:266
Definition: vf.h:56
unsigned int flags
Definition: mp_image.h:126
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:190
#define MP_NOPTS_VALUE
Definition: vf.h:118
#define IMGFMT_411P
Definition: img_format.h:132
mp_image_t * dmpi
Definition: vf.h:85
#define MP_IMGTYPE_IP
Definition: mp_image.h:106
#define IMGFMT_BGR15BE
Definition: img_format.h:96