static int Cvt420422 (VideoFilter * f, VideoFrame * frame) { ThisFilter * filter = (ThisFilter *) f; int X, Y, field; unsigned char * lineout0, * lineout1, * linein; TF_VARS; TF_START; for (field = 1; field > -1; field--) { lineout0 = frame->buf + filter->uoff + filter->ocsize + field * filter->ocsize; lineout1 = lineout0 + filter->cwidth; linein = frame->buf + filter->uoff + filter->icsize + field * filter->icsize; for (Y = 0; Y < filter->cheight; Y++) { lineout0 -= filter->cwidth * 2; lineout1 -= filter->cwidth * 2; linein -= filter->cwidth; for (X = 0; X < filter->cwidth; X++) lineout0[X] = lineout1[X] = linein[X]; } } frame->size = filter->osize; frame->codec = FMT_YUV422P; TF_END(filter, "ConvertYV12->YUV420P: "); return 0; }
static int Cvt422420 (VideoFilter * f, VideoFrame * frame) { ThisFilter * filter = (ThisFilter *) f; int X, Y, field; unsigned char * lineout, * linein0, * linein1; TF_VARS; TF_START; for (field = 0; field < 2; field++) { lineout = frame->buf + filter->uoff + field * filter->ocsize; linein0 = frame->buf + filter->uoff + field * filter->icsize; linein1 = linein0 + filter->cwidth; for (Y = 0; Y < filter->cheight; Y++) { for (X = 0; X < filter->cwidth; X++) lineout[X] = (linein0[X] + linein1[X]) / 2; lineout += filter->cwidth; linein0 += filter->cwidth * 2; linein1 += filter->cwidth * 2; } } frame->size = filter->osize; frame->codec = FMT_YV12; TF_END(filter, "ConvertYUV422P->YV12: "); return 0; }
int invert(VideoFilter *vf, VideoFrame *frame) { int size = frame->size; unsigned char *buf = frame->buf; TF_VARS; (void)vf; TF_START; while (size--) { *buf = 255 - (*buf); buf++; } TF_END((ThisFilter *)vf, "Invert"); return 0; }
static int pp(VideoFilter *vf, VideoFrame *frame, int field) { (void)field; ThisFilter* tf = (ThisFilter*)vf; TF_VARS; TF_START; tf->src[0] = tf->dst[0] = frame->buf; tf->src[1] = tf->dst[1] = frame->buf + tf->ysize; tf->src[2] = tf->dst[2] = frame->buf + tf->ysize + tf->csize; if (frame->qscale_table == NULL) frame->qstride = 0; tf->ysize = (frame->width) * (frame->height); tf->csize = tf->ysize / 4; tf->width = frame->width; tf->height = frame->height; tf->srcStride[0] = tf->ysize / (tf->height); tf->srcStride[1] = tf->csize / (tf->height) * 2; tf->srcStride[2] = tf->csize / (tf->height) * 2; tf->dstStride[0] = tf->ysize / (tf->height); tf->dstStride[1] = tf->csize / (tf->height) * 2; tf->dstStride[2] = tf->csize / (tf->height) * 2; pp_postprocess( (const uint8_t**)tf->src, tf->srcStride, tf->dst, tf->dstStride, frame->width, frame->height, (signed char *)(frame->qscale_table), frame->qstride, tf->mode, tf->context, PP_FORMAT_420); TF_END(tf, "PostProcess: "); return 0; }
static int vflip(VideoFilter *vf, VideoFrame *frame, int field) { (void)field; if (frame->codec != FMT_YV12) { fprintf(stderr, "codec %d unsupported for vflip, skipping\n", frame->codec); return 0; } TF_VARS; (void)vf; TF_START; int ouroffsets[3]; memcpy(ouroffsets, frame->offsets, 3 * sizeof(int)); qsort(ouroffsets, 3, sizeof(int), comp); int datasize; datasize = (ouroffsets[1] - ouroffsets[0]) / frame->height; if (!swap(frame, datasize, ouroffsets[0], 0)) return 0; datasize = (ouroffsets[2] - ouroffsets[1]) / frame->height; if (!swap(frame, datasize, ouroffsets[1], 0)) return 0; datasize = (frame->size - ouroffsets[2]) / frame->height; if (!swap(frame, datasize, ouroffsets[2], 0)) return 0; TF_END((ThisFilter *)vf, "VFlip"); return 1; }