mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-26 21:00:21 +00:00
video: remove internal QP passing
This was required by vf_pp, which was just removed. vf_dlopen has this stuff in its API. This API is considered stable, so the related fields are not removed from it. But the fields are always 0 now, so there's no point in keeping the example program around. vf_pullup.c did some extremely awkward passthrough of this information, but didn't actually use it.
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
# 02110-1301 USA
|
||||
#
|
||||
|
||||
FILTERS = showqscale telecine tile rectangle framestep ildetect
|
||||
FILTERS = telecine tile rectangle framestep ildetect
|
||||
COMMON = filterutils.o
|
||||
|
||||
OBJECTS = $(patsubst %,%.o,$(FILTERS)) $(COMMON)
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Rudolf Polzer <divVerent@xonotic.org>
|
||||
*
|
||||
* This file is part of mpv's vf_dlopen examples.
|
||||
*
|
||||
* mpv's vf_dlopen examples are free software; you can redistribute them and/or
|
||||
* modify them under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version 2.1 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* mpv's vf_dlopen examples are distributed in the hope that they will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with mpv's vf_dlopen examples; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "vf_dlopen.h"
|
||||
|
||||
/*
|
||||
* qscale visualizer
|
||||
*
|
||||
* usage: --vf=dlopen=/path/to/showqscale.so
|
||||
*
|
||||
* uses reddish colors for high QPs, and greenish colors for low QPs
|
||||
*/
|
||||
|
||||
#define PLANE_Y 0
|
||||
#define PLANE_U 1
|
||||
#define PLANE_V 2
|
||||
|
||||
static int qs_put_image(struct vf_dlopen_context *ctx)
|
||||
{
|
||||
unsigned int x, y, p;
|
||||
|
||||
assert(ctx->inpic.planes == ctx->outpic[0].planes);
|
||||
|
||||
for (p = 0; p < ctx->outpic[0].planes; ++p) {
|
||||
assert(ctx->inpic.planewidth[p] == ctx->outpic[0].planewidth[p]);
|
||||
assert(ctx->inpic.planeheight[p] == ctx->outpic[0].planeheight[p]);
|
||||
if ((p == PLANE_U || p == PLANE_V) && ctx->inpic_qscale)
|
||||
continue;
|
||||
#if 0
|
||||
// copy as is
|
||||
for (y = 0; y < ctx->outpic[0].planeheight[p]; ++y)
|
||||
memcpy(
|
||||
&ctx->outpic[0].plane[p][ctx->outpic[0].planestride[p] * y],
|
||||
&inpic[ctx->outpic[0].planeofs[p] + ctx->inpic.planestride[p] * y],
|
||||
ctx->outpic[0].planewidth[p]
|
||||
);
|
||||
#else
|
||||
// reduce contrast
|
||||
for (y = 0; y < ctx->outpic[0].planeheight[p]; ++y)
|
||||
for (x = 0; x < ctx->outpic[0].planewidth[p]; ++x)
|
||||
ctx->outpic[0].plane[p][ctx->outpic[0].planestride[p] * y + x] =
|
||||
0x20 + ((ctx->inpic.plane[p][ctx->inpic.planestride[p] * y + x] * 3) >> 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ctx->inpic_qscale) {
|
||||
int qmin = 255;
|
||||
int qmax = -255;
|
||||
|
||||
// clear U plane
|
||||
p = PLANE_U;
|
||||
for (y = 0; y < ctx->outpic[0].planeheight[p]; ++y)
|
||||
memset(
|
||||
&ctx->outpic[0].plane[p][ctx->outpic[0].planestride[p] * y],
|
||||
0x80,
|
||||
ctx->outpic[0].planewidth[p]
|
||||
);
|
||||
|
||||
// replace V by the qp (0 = green, 12 = red)
|
||||
p = PLANE_V;
|
||||
for (y = 0; y < ctx->outpic[0].planeheight[p]; ++y)
|
||||
for (x = 0; x < ctx->outpic[0].planewidth[p]; ++x) {
|
||||
int q = ctx->inpic_qscale[
|
||||
(x >> (ctx->inpic_qscaleshift - ctx->inpic.planexshift[p])) +
|
||||
(y >> (ctx->inpic_qscaleshift - ctx->inpic.planeyshift[p])) * ctx->inpic_qscalestride];
|
||||
if (q < qmin)
|
||||
qmin = q;
|
||||
if (q > qmax)
|
||||
qmax = q;
|
||||
int v = 128 + 21 * (q - 6); // range: 0 = green, 12 = red
|
||||
if (v < 0)
|
||||
v = 0;
|
||||
if (v > 255)
|
||||
v = 255;
|
||||
ctx->outpic[0].plane[p][ctx->outpic[0].planestride[p] * y + x] = v;
|
||||
}
|
||||
|
||||
// printf("qscale range: %d .. %d\n", qmin, qmax);
|
||||
}
|
||||
|
||||
ctx->outpic[0].pts = ctx->inpic.pts;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vf_dlopen_getcontext(struct vf_dlopen_context *ctx, int argc, const char **argv)
|
||||
{
|
||||
VF_DLOPEN_CHECK_VERSION(ctx);
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
static struct vf_dlopen_formatpair map[] = {
|
||||
{ "yuv420p", "yuv420p" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
ctx->format_mapping = map;
|
||||
ctx->put_image = qs_put_image;
|
||||
return 1;
|
||||
}
|
||||
@@ -820,12 +820,6 @@ api_statement_check \
|
||||
libavutil/frame.h \
|
||||
'enum AVFrameSideDataType type = AV_FRAME_DATA_SKIP_SAMPLES'
|
||||
|
||||
api_statement_check \
|
||||
"libavutil QP API" \
|
||||
HAVE_AVUTIL_QP_API \
|
||||
libavutil/frame.h \
|
||||
'av_frame_get_qp_table(NULL, NULL, NULL)'
|
||||
|
||||
api_statement_check \
|
||||
"libavcodec av_vdpau_alloc_context()" \
|
||||
HAVE_AVCODEC_VDPAU_ALLOC_CONTEXT \
|
||||
|
||||
@@ -62,10 +62,6 @@ struct vf_priv_s {
|
||||
unsigned int outbufferlen;
|
||||
mp_image_t *outbuffermpi;
|
||||
|
||||
// qscale buffer
|
||||
unsigned char *qbuffer;
|
||||
size_t qbuffersize;
|
||||
|
||||
unsigned int outfmt;
|
||||
|
||||
int argc;
|
||||
@@ -182,55 +178,17 @@ static void uninit(struct vf_instance *vf)
|
||||
DLLClose(vf->priv->dll);
|
||||
vf->priv->dll = NULL;
|
||||
}
|
||||
if (vf->priv->qbuffer) {
|
||||
free(vf->priv->qbuffer);
|
||||
vf->priv->qbuffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int norm_qscale(int qscale, int type)
|
||||
{
|
||||
switch (type) {
|
||||
case 0: // MPEG-1
|
||||
return qscale;
|
||||
case 1: // MPEG-2
|
||||
return qscale >> 1;
|
||||
case 2: // H264
|
||||
return qscale >> 2;
|
||||
case 3: // VP56
|
||||
return (63 - qscale + 2) >> 2;
|
||||
}
|
||||
return qscale;
|
||||
}
|
||||
|
||||
static int filter(struct vf_instance *vf, struct mp_image *mpi)
|
||||
{
|
||||
int i, k;
|
||||
|
||||
if (!mpi)
|
||||
return 0;
|
||||
|
||||
set_imgprop(&vf->priv->filter.inpic, mpi);
|
||||
if (mpi->qscale) {
|
||||
if (mpi->qscale_type != 0) {
|
||||
k = mpi->qstride * ((mpi->h + 15) >> 4);
|
||||
if (vf->priv->qbuffersize != k) {
|
||||
vf->priv->qbuffer = realloc(vf->priv->qbuffer, k);
|
||||
vf->priv->qbuffersize = k;
|
||||
}
|
||||
for (i = 0; i < k; ++i)
|
||||
vf->priv->qbuffer[i] = norm_qscale(mpi->qscale[i],
|
||||
mpi->qscale_type);
|
||||
vf->priv->filter.inpic_qscale = vf->priv->qbuffer;
|
||||
} else
|
||||
vf->priv->filter.inpic_qscale = mpi->qscale;
|
||||
vf->priv->filter.inpic_qscalestride = mpi->qstride;
|
||||
vf->priv->filter.inpic_qscaleshift = 4;
|
||||
} else {
|
||||
vf->priv->filter.inpic_qscale = NULL;
|
||||
vf->priv->filter.inpic_qscalestride = 0;
|
||||
vf->priv->filter.inpic_qscaleshift = 0;
|
||||
}
|
||||
vf->priv->filter.inpic_qscale = NULL;
|
||||
vf->priv->filter.inpic_qscalestride = 0;
|
||||
vf->priv->filter.inpic_qscaleshift = 0;
|
||||
vf->priv->filter.inpic.pts = mpi->pts;
|
||||
|
||||
struct mp_image *out[FILTER_MAX_OUTCNT] = {0};
|
||||
|
||||
@@ -40,7 +40,6 @@ struct vf_priv_s {
|
||||
struct pullup_context *ctx;
|
||||
int init;
|
||||
int fakecount;
|
||||
char *qbuf;
|
||||
double lastpts;
|
||||
int junk_left, junk_right, junk_top, junk_bottom;
|
||||
int strict_breaks, metric_plane;
|
||||
@@ -51,8 +50,6 @@ static void reset(struct vf_instance *vf)
|
||||
{
|
||||
if (vf->priv->ctx)
|
||||
pullup_free_context(vf->priv->ctx);
|
||||
free(vf->priv->qbuf);
|
||||
vf->priv->qbuf = NULL;
|
||||
vf->priv->init = 0;
|
||||
struct pullup_context *c;
|
||||
vf->priv->ctx = c = pullup_alloc_context();
|
||||
@@ -87,7 +84,6 @@ static void init_pullup(struct vf_instance *vf, mp_image_t *mpi)
|
||||
pullup_init_context(c);
|
||||
|
||||
vf->priv->init = 1;
|
||||
vf->priv->qbuf = malloc(c->w[3]);
|
||||
}
|
||||
|
||||
static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
|
||||
@@ -96,7 +92,6 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
|
||||
struct pullup_buffer *b;
|
||||
struct pullup_frame *f;
|
||||
int p;
|
||||
int i;
|
||||
double pts = mpi->pts;
|
||||
struct mp_image *dmpi = NULL;
|
||||
|
||||
@@ -119,11 +114,6 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
|
||||
mpi->chroma_width, mpi->chroma_height,
|
||||
c->stride[2], mpi->stride[2]);
|
||||
}
|
||||
if (mpi->qscale) {
|
||||
memcpy(b->planes[3], mpi->qscale, c->w[3]);
|
||||
memcpy(b->planes[3]+c->w[3], mpi->qscale, c->w[3]);
|
||||
}
|
||||
|
||||
p = mpi->fields & MP_IMGFIELD_TOP_FIRST ? 0 :
|
||||
(mpi->fields & MP_IMGFIELD_ORDERED ? 1 : 0);
|
||||
|
||||
@@ -178,23 +168,6 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Average qscale tables from both frames. */
|
||||
if (mpi->qscale) {
|
||||
for (i=0; i<c->w[3]; i++) {
|
||||
vf->priv->qbuf[i] = (f->ofields[0]->planes[3][i]
|
||||
+ f->ofields[1]->planes[3][i+c->w[3]])>>1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* Take worst of qscale tables from both frames. */
|
||||
if (mpi->qscale) {
|
||||
for (i=0; i<c->w[3]; i++) {
|
||||
vf->priv->qbuf[i] = MAX(f->ofields[0]->planes[3][i], f->ofields[1]->planes[3][i+c->w[3]]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If the frame isn't already exportable... */
|
||||
if (!f->buffer)
|
||||
pullup_pack_frame(c, f);
|
||||
@@ -222,12 +195,6 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
|
||||
|
||||
dmpi->pts = f->pts;
|
||||
|
||||
// Warning: entirely bogus memory management of qscale
|
||||
if (mpi->qscale) {
|
||||
dmpi->qscale = vf->priv->qbuf;
|
||||
dmpi->qstride = mpi->qstride;
|
||||
dmpi->qscale_type = mpi->qscale_type;
|
||||
}
|
||||
pullup_release_frame(f);
|
||||
|
||||
skip:
|
||||
|
||||
Reference in New Issue
Block a user