Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_zscale: fix mapping of zimg_chroma_location_e to AVChromaLocation

2021-10-28 Thread Jan Ekström
On Thu, Oct 28, 2021 at 1:25 AM Paul B Mahol  wrote:
>
> probably fine

This can be verified by specifying - say - chromal topleft, and seeing
that the ffmpeg.c Output: bit right now would end up being "left"
(most likely). While if you apply this, you should get "topleft".

Technically if the values were unsanitized, having a mapping function
like we have the other way would be better, but since the code already
utilized +/- 1... I went with that way of just fixing the logic to go
the right way.

For verification of the internal values, something like the following
can be utilized:

diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 1288c5efc1..50df90e9ec 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -126,6 +126,8 @@ typedef struct ZScaleContext {
 enum AVColorPrimaries in_primaries, out_primaries;
 enum AVColorRange in_range, out_range;
 enum AVChromaLocation in_chromal, out_chromal;
+
+int lel;
 } ZScaleContext;

 static av_cold int init(AVFilterContext *ctx)
@@ -687,6 +689,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)

 update_output_color_information(s, out);

+av_log_once(s, AV_LOG_VERBOSE, AV_LOG_TRACE, &(s->lel),
+"output frame chroma location: %s "
+"(s->chromal: %d, dst_format.chroma_location: %d)\n",
+av_chroma_location_name(out->chroma_location),
+s->chromal, s->dst_format.chroma_location);
+
 av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
   (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
   (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_zscale: fix mapping of zimg_chroma_location_e to AVChromaLocation

2021-10-27 Thread Paul B Mahol
probably fine
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/2] avfilter/vf_zscale: fix mapping of zimg_chroma_location_e to AVChromaLocation

2021-10-27 Thread Jan Ekström
The AVChromaLocation values are one higher than zimg's, not one
lower as the undefined value is set to zero (as opposed to zimg's
-1).
---
 libavfilter/vf_zscale.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 439c0c8548..1288c5efc1 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -569,7 +569,7 @@ static void update_output_color_information(ZScaleContext 
*s, AVFrame *frame)
 frame->color_trc = (int)s->dst_format.transfer_characteristics;
 
 if (s->chromal != -1)
-frame->chroma_location = (int)s->dst_format.chroma_location - 1;
+frame->chroma_location = (int)s->dst_format.chroma_location + 1;
 }
 
 static int filter_frame(AVFilterLink *link, AVFrame *in)
-- 
2.31.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".