Hi,

On 31.08.2015 14:32, Ronald S. Bultje wrote:
> On Mon, Aug 31, 2015 at 8:09 AM, Andreas Cadhalpun <
> andreas.cadhal...@googlemail.com> wrote:
>> These defines are used in libavcodec and libavfilter.
>> Since libavfilter only uses them for ff_norm_qscale, we could also move
>> that
>> to libavcodec and call it avpriv_norm_qscale.
>>
>> Do you like this idea better?
>>
> 
> Yes, let's do that (I think that's what we originally had, maybe with a
> different prefix, right?). At least it keeps libavutil clean(er) and
> contains this hack to libavcodec alone. It's not great but I don't see
> anything better, thanks for looking at this.

OK, patch for that attached.

> The larger problem is anyway the qscale part of FF_API_AVFRAME_LAVC, which
>> we need for av_frame_get_qp_table. I don't see an easy solution for that.
> 
> 
> That was supposed to become side-data, we just never changed our code,
> right?

I think so.

> I can look at that today if you want.

That would be great.

> Is there any other upcoming deprecation that fails compile+fate?

There is FF_API_DEBUG_MV, but you know that.

And some of the more recent ones are problematic:
Build failure:
FF_API_MPV_OPT
FF_API_CODED_FRAME
FF_API_MOTION_EST
FF_API_WITHOUT_PREFIX
FF_API_QP_TYPE
FF_API_CRYPTO_CONTEXT

Fate failure:
FF_API_AVCTX_TIMEBASE

Best regards,
Andreas
>From adb0b32a366feb4d6784fd91f4481aa32219af6b Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
Date: Mon, 31 Aug 2015 23:39:43 +0200
Subject: [PATCH] avcodec: add qscale.h for FF_QSCALE_TYPE_* and
 avpriv_norm_qscale

This fixes building with FF_API_QSCALE_TYPE disabled.

Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
---
 libavcodec/mjpegdec.c  |  1 +
 libavcodec/mpegvideo.h |  1 +
 libavcodec/qscale.h    | 44 ++++++++++++++++++++++++++++++++++++++++++++
 libavfilter/internal.h | 16 ----------------
 libavfilter/vf_fspp.c  |  3 ++-
 libavfilter/vf_pp7.c   |  3 ++-
 libavfilter/vf_spp.c   |  3 ++-
 libavfilter/vf_uspp.c  |  3 ++-
 8 files changed, 54 insertions(+), 20 deletions(-)
 create mode 100644 libavcodec/qscale.h

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 818f8c9..36e9afe 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -46,6 +46,7 @@
 #include "tiff.h"
 #include "exif.h"
 #include "bytestream.h"
+#include "qscale.h"
 
 
 static int build_vlc(VLC *vlc, const uint8_t *bits_table,
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 8492045..eb0fcf3 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -52,6 +52,7 @@
 #include "mpegutils.h"
 #include "mpeg12data.h"
 #include "qpeldsp.h"
+#include "qscale.h"
 #include "thread.h"
 #include "videodsp.h"
 
diff --git a/libavcodec/qscale.h b/libavcodec/qscale.h
new file mode 100644
index 0000000..7927694
--- /dev/null
+++ b/libavcodec/qscale.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it 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.
+ *
+ * FFmpeg is distributed in the hope that it 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "version.h"
+
+#if FF_API_QSCALE_TYPE
+#include "avcodec.h"
+#else
+#define FF_QSCALE_TYPE_MPEG1 0
+#define FF_QSCALE_TYPE_MPEG2 1
+#define FF_QSCALE_TYPE_H264  2
+#define FF_QSCALE_TYPE_VP56  3
+#endif
+
+/**
+ * Normalize the qscale factor
+ * FIXME the H264 qscale is a log based scale, mpeg1/2 is not, the code below
+ *       cannot be optimal
+ */
+static inline int avpriv_norm_qscale(int qscale, int type)
+{
+    switch (type) {
+    case FF_QSCALE_TYPE_MPEG1: return qscale;
+    case FF_QSCALE_TYPE_MPEG2: return qscale >> 1;
+    case FF_QSCALE_TYPE_H264:  return qscale >> 2;
+    case FF_QSCALE_TYPE_VP56:  return (63 - qscale + 2) >> 2;
+    }
+    return qscale;
+}
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index 7dde2e1..1a4f6f5 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -390,20 +390,4 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name);
  */
 void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter);
 
-/**
- * Normalize the qscale factor
- * FIXME the H264 qscale is a log based scale, mpeg1/2 is not, the code below
- *       cannot be optimal
- */
-static inline int ff_norm_qscale(int qscale, int type)
-{
-    switch (type) {
-    case FF_QSCALE_TYPE_MPEG1: return qscale;
-    case FF_QSCALE_TYPE_MPEG2: return qscale >> 1;
-    case FF_QSCALE_TYPE_H264:  return qscale >> 2;
-    case FF_QSCALE_TYPE_VP56:  return (63 - qscale + 2) >> 2;
-    }
-    return qscale;
-}
-
 #endif /* AVFILTER_INTERNAL_H */
diff --git a/libavfilter/vf_fspp.c b/libavfilter/vf_fspp.c
index 7bdaa91..01aed9a 100644
--- a/libavfilter/vf_fspp.c
+++ b/libavfilter/vf_fspp.c
@@ -35,6 +35,7 @@
  * project, and ported by Arwa Arif for FFmpeg.
  */
 
+#include "libavcodec/qscale.h"
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
@@ -206,7 +207,7 @@ static void filter(FSPPContext *p, uint8_t *dst, uint8_t *src,
                     if (t < 0) t = 0;                   //t always < width-2
 
                     t = qp_store[qy + (t >> qpsh)];
-                    t = ff_norm_qscale(t, p->qscale_type);
+                    t = avpriv_norm_qscale(t, p->qscale_type);
 
                     if (t != p->prev_q) p->prev_q = t, p->mul_thrmat((int16_t *)(&p->threshold_mtx_noq[0]), (int16_t *)(&p->threshold_mtx[0]), t);
                     p->column_fidct((int16_t *)(&p->threshold_mtx[0]), block + x * 8, block3 + x * 8, 8); //yes, this is a HOTSPOT
diff --git a/libavfilter/vf_pp7.c b/libavfilter/vf_pp7.c
index 9e78c39..dc7a07a 100644
--- a/libavfilter/vf_pp7.c
+++ b/libavfilter/vf_pp7.c
@@ -27,6 +27,7 @@
  * project, and ported by Arwa Arif for FFmpeg.
  */
 
+#include "libavcodec/qscale.h"
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
@@ -240,7 +241,7 @@ static void filter(PP7Context *p, uint8_t *dst, uint8_t *src,
                 qp = p->qp;
             else {
                 qp = qp_store[ (FFMIN(x, width - 1) >> qps) + (FFMIN(y, height - 1) >> qps) * qp_stride];
-                qp = ff_norm_qscale(qp, p->qscale_type);
+                qp = avpriv_norm_qscale(qp, p->qscale_type);
             }
             for (; x < end; x++) {
                 const int index = x + y * stride + (8 - 3) * (1 + stride) + 8; //FIXME silly offset
diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c
index b75f5f3..fc82f88 100644
--- a/libavfilter/vf_spp.c
+++ b/libavfilter/vf_spp.c
@@ -31,6 +31,7 @@
  * ported by Clément Bœsch for FFmpeg.
  */
 
+#include "libavcodec/qscale.h"
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
@@ -272,7 +273,7 @@ static void filter(SPPContext *p, uint8_t *dst, uint8_t *src,
             } else{
                 const int qps = 3 + is_luma;
                 qp = qp_table[(FFMIN(x, width - 1) >> qps) + (FFMIN(y, height - 1) >> qps) * qp_stride];
-                qp = FFMAX(1, ff_norm_qscale(qp, p->qscale_type));
+                qp = FFMAX(1, avpriv_norm_qscale(qp, p->qscale_type));
             }
             for (i = 0; i < count; i++) {
                 const int x1 = x + offset[i + count - 1][0];
diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c
index a89ca1f..2571ae8 100644
--- a/libavfilter/vf_uspp.c
+++ b/libavfilter/vf_uspp.c
@@ -27,6 +27,7 @@
  * ported by Arwa Arif for FFmpeg.
  */
 
+#include "libavcodec/qscale.h"
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
@@ -224,7 +225,7 @@ static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3],
             for (x = 0; x < (width>>4); x++)
                 qpsum += qp_store[x + y * qp_stride];
         }
-        p->frame->quality = ff_norm_qscale((qpsum + qpcount/2) / qpcount, p->qscale_type) * FF_QP2LAMBDA;
+        p->frame->quality = avpriv_norm_qscale((qpsum + qpcount/2) / qpcount, p->qscale_type) * FF_QP2LAMBDA;
     }
 //    init per MB qscale stuff FIXME
     p->frame->height = height;
-- 
2.5.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to