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"
43 #include "libswscale/swscale.h"
187 #define OFFSET(x) offsetof(MPContext, x)
188 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
196 void ff_mp_msg(
int mod,
int lev,
const char *format, ... ){
198 va_start(va, format);
226 if (vf->next->draw_slice) {
227 vf->next->draw_slice(vf->next,src,stride,w,h,x,y);
235 memcpy_pic(vf->dmpi->planes[0]+y*vf->dmpi->stride[0]+vf->dmpi->bpp/8*x,
236 src[0], vf->dmpi->bpp/8*w, h, vf->dmpi->stride[0], stride[0]);
239 memcpy_pic(vf->dmpi->planes[0]+y*vf->dmpi->stride[0]+x, src[0],
240 w, h, vf->dmpi->stride[0], stride[0]);
241 memcpy_pic(vf->dmpi->planes[1]+(y>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[1]+(x>>vf->dmpi->chroma_x_shift),
242 src[1], w>>vf->dmpi->chroma_x_shift, h>>vf->dmpi->chroma_y_shift, vf->dmpi->stride[1], stride[1]);
243 memcpy_pic(vf->dmpi->planes[2]+(y>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[2]+(x>>vf->dmpi->chroma_x_shift),
244 src[2], w>>vf->dmpi->chroma_x_shift, h>>vf->dmpi->chroma_y_shift, vf->dmpi->stride[2], stride[2]);
252 if(x0==0 && w==mpi->
width){
258 for(y=y0;y<y0+h;y+=2){
267 for(y=y0;y<y0+h;y++){
270 unsigned int* p=(
unsigned int*) dst;
274 #define CLEAR_PACKEDYUV_PATTERN 0x00800080
275 #define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x80008000
277 #define CLEAR_PACKEDYUV_PATTERN 0x80008000
278 #define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x00800080
288 memset(dst,0,(mpi->
bpp>>3)*w);
305 int number = mp_imgtype >> 16;
310 if(vf->
w==0 && w>0) vf->
w=w;
311 if(vf->
h==0 && h>0) vf->
h=h;
320 if (w == -1) w = vf->
w;
321 if (h == -1) h = vf->
h;
327 switch(mp_imgtype & 0xff){
366 mpi->
type=mp_imgtype;
367 mpi->
w=vf->
w; mpi->
h=vf->
h;
400 "ff_vf_get_image: Tried to allocate a format that can not be allocated!\n");
409 w2=((w+
align)&(~align));
442 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",
485 for(i=0; i<4 && mpi->
stride[i]; i++){
509 unsigned int voflags,
unsigned int outfmt){
516 int flags=vf->next->query_format(vf->next,outfmt);
523 miss=vf->default_reqs - (flags&vf->default_reqs);
578 if(!args || 1!=sscanf(args,
"%255[^:=]", name)){
582 args += strlen(name);
587 if(!filters[i] || !strcmp(name, filters[i]->name))
597 "'%s' is a wrapped MPlayer filter (libmpcodecs). This filter may be removed\n"
598 "once it has been ported to a native libavfilter.\n", name);
600 memset(&m->
vf,0,
sizeof(m->
vf));
614 const m_struct_t* st = vf->
info->
opts;
615 void* vf_priv = m_struct_alloc(st);
617 for(n = 0 ; args && args[2*
n] ; n++)
618 m_struct_set(st,vf_priv,args[2*n],args[2*n+1]);
622 if(args && !strcmp(args[0],
"_oldargs_"))
623 args = (
char**)args[1];
790 .priv_class = &mp_class,
This structure describes decoded (raw) audio or video data.
#define AV_CPU_FLAG_SSE3
Prescott SSE3 functions.
const char * name
Filter name.
void * priv
private data for use by the filter
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
int(* query_format)(struct vf_instance *vf, unsigned int fmt)
int h
agreed upon image height
unsigned int default_caps
packed RGB 8:8:8, 24bpp, RGBRGB...
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int repeat_pict
When decoding, this signals how much the picture must be delayed.
static const AVOption mp_options[]
#define AV_CPU_FLAG_SSE2
PIV SSE2 functions.
mp_image_t * ff_vf_get_image(vf_instance_t *vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
const vf_info_t ff_vf_info_uspp
const vf_info_t ff_vf_info_pp7
#define MP_IMGFLAG_PRESERVE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
#define MP_IMGTYPE_EXPORT
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
#define MP_IMGFLAG_READABLE
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 ...
static int request_frame(AVFilterLink *outlink)
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
void(* get_image)(struct vf_instance *vf, mp_image_t *mpi)
int ff_vf_next_config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt)
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
#define AV_CPU_FLAG_3DNOW
AMD 3DNOW.
packed RGB 8:8:8, 24bpp, BGRBGR...
const char * name
Pad name.
#define MP_IMGFIELD_REPEAT_FIRST
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstr...
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 ...
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
as above, but U and V bytes are swapped
MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstre...
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static int config_inprops(AVFilterLink *inlink)
#define AV_CPU_FLAG_SSE
SSE functions.
unsigned int default_reqs
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
static double av_q2d(AVRational a)
Convert rational to double.
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
enum AVPixelFormat pix_fmt
int interlaced_frame
The content of the picture is interlaced.
void ff_mp_image_setfmt(mp_image_t *mpi, unsigned int out_fmt)
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
void ff_free_mp_image(mp_image_t *mpi)
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
static const vf_info_t *const filters[]
int(* put_image)(struct vf_instance *vf, mp_image_t *mpi, double pts)
A filter pad used for either input or output.
A link between two filters.
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define AV_CPU_FLAG_SSE4
Penryn SSE4.1 functions.
void(* draw_slice)(struct vf_instance *vf, unsigned char **src, int *stride, int w, int h, int x, int y)
#define MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define MP_IMGTYPE_STATIC
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static struct @132 conversion_map[]
int ff_vf_next_control(struct vf_instance *vf, int request, void *data)
static int vf_default_query_format(struct vf_instance *vf, unsigned int fmt)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
AVFilterContext * src
source filter
XVideo Motion Acceleration via common packet passing.
void(* uninit)(struct vf_instance *vf)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define CLEAR_PACKEDYUV_PATTERN_SWAPPED
#define CLEAR_PACKEDYUV_PATTERN
WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstrea...
AVPixelFormat
Pixel format.
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
int(* control)(struct vf_instance *vf, int request, void *data)
int w
agreed upon image width
H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstre...
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
int(* vf_open)(struct vf_instance *vf, char *args)
#define MP_IMGFLAG_PREFER_ALIGNED_STRIDE
#define MP_IMGFLAG_DRAW_CALLBACK
enum AVPixelFormat ff_mp2ff_pix_fmt(int mp)
mp_image_t * numbered_images[NUM_NUMBERED_MPI]
VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstrea...
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 ...
#define MP_IMGFLAGMASK_COLORS
void(* start_slice)(struct vf_instance *vf, mp_image_t *mpi)
void ff_init_avcodec(void)
void ff_vf_clone_mpi_attributes(mp_image_t *dst, mp_image_t *src)
#define MP_IMGFIELD_TOP_FIRST
#define AV_CPU_FLAG_SSE42
Nehalem SSE4.2 functions.
int format
agreed upon media format
void ff_mp_image_alloc_planes(mp_image_t *mpi)
static const AVFilterPad mp_outputs[]
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
Main libavfilter public API header.
mp_image_t * export_images[1]
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
AVFilterLink ** outputs
array of pointers to output links
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
const AVS_VideoInfo int align
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define MP_IMGFLAG_RGB_PALETTE
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static av_cold void uninit(AVFilterContext *ctx)
const vf_info_t ff_vf_info_eq
#define AV_CPU_FLAG_MMX
standard MMX
mp_image_t * temp_images[1]
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 ...
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
const vf_info_t ff_vf_info_softpulldown
#define memcpy_pic(d, s, b, h, ds, ss)
MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstr...
int stride[MP_MAX_PLANES]
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 ...
BYTE int const BYTE int int int height
Describe the class of an AVClass context structure.
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
const vf_info_t ff_vf_info_eq2
static const AVFilterPad inputs[]
AVFilterLink ** inputs
array of pointers to input links
#define MP_IMGFLAG_ALLOCATED
unsigned char * planes[MP_MAX_PLANES]
void void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level...
#define AV_CPU_FLAG_3DNOWEXT
AMD 3DNowExt.
const vf_info_t ff_vf_info_fspp
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
AVFilterContext * dst
dest filter
#define AV_CPU_FLAG_MMX2
SSE integer functions or AMD MMX ext.
#define MP_IMGFIELD_INTERLACED
vf_instance_t * vf_open_filter(vf_instance_t *next, const char *name, char **args)
AVFrame * av_frame_clone(AVFrame *src)
Create a new frame that references the same data as src.
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
int ff_mp_msg_test(int mod, int lev)
#define MP_IMGFLAGMASK_RESTRICTIONS
int(* config)(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt)
static av_cold int init(AVFilterContext *ctx)
void ff_mp_msg(int mod, int lev, const char *format,...)
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
#define MP_IMGFLAG_PLANAR
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
void ff_vf_next_draw_slice(struct vf_instance *vf, unsigned char **src, int *stride, int w, int h, int x, int y)
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
int ff_vf_next_put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
static int query_formats(AVFilterContext *ctx)
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
#define MP_IMGTYPE_NUMBERED
int top_field_first
If the content is interlaced, is top field displayed first.
static int config_outprops(AVFilterLink *outlink)
void ff_vf_mpi_clear(mp_image_t *mpi, int x0, int y0, int w, int h)
#define AVFILTER_DEFINE_CLASS(fname)
vf_image_context_t imgctx
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
mp_image_t * static_images[2]
unsigned int ff_vf_match_csp(vf_instance_t **vfp, const unsigned int *list, unsigned int preferred)
mp_image_t * ff_new_mp_image(int w, int h)
#define MP_IMGFLAG_TYPE_DISPLAYED
static const AVFilterPad mp_inputs[]
#define AV_CPU_FLAG_AVX
AVX functions: requires OS support even if YMM registers aren't used.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define MP_IMGFLAG_DIRECT
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
8 bit with PIX_FMT_RGB32 palette
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
attribute_deprecated int type
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
#define AV_CPU_FLAG_SSSE3
Conroe SSSE3 functions.
#define MP_IMGFLAG_SWAPPED
enum AVPixelFormat in_pix_fmt
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
const vf_info_t ff_vf_info_ilpack
#define VFCAP_ACCEPT_STRIDE
int ff_vf_next_query_format(struct vf_instance *vf, unsigned int fmt)
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define AV_NOPTS_VALUE
Undefined timestamp value.
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
struct vf_instance * next