Re: [FFmpeg-devel] [PATCH 1/1] avcodec/exr: add support data windows larger or outside display window

2020-09-07 Thread Paul B Mahol
On Mon, Sep 07, 2020 at 02:54:35PM -0700, mindm...@gmail.com wrote:
> From: Mark Reid 
> 
> Hi,
> The following patch adds exr support for data windows that are larger or 
> outside the display window. 
> This adds support for both scanline and tiled formats.
> 
> Here are the added exr files for the fate tests. Could somebody upload them 
> to fate for me?
> https://www.dropbox.com/s/m0941dmjoejskp0/exr_datawindow_fate_files.zip
> 

Will upload files in next 24h and apply patch in next 96h.
___
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 1/1] avcodec/exr: add support data windows larger or outside display window

2020-09-07 Thread mindmark
From: Mark Reid 

Hi,
The following patch adds exr support for data windows that are larger or 
outside the display window. 
This adds support for both scanline and tiled formats.

Here are the added exr files for the fate tests. Could somebody upload them to 
fate for me?
https://www.dropbox.com/s/m0941dmjoejskp0/exr_datawindow_fate_files.zip

---
 libavcodec/exr.c  | 110 ++
 tests/fate/image.mak  |  31 +
 .../fate/exr-rgb-scanline-float-zip-dw-large  |   6 +
 .../fate/exr-rgb-scanline-half-piz-dw-large   |   6 +
 .../fate/exr-rgb-scanline-half-zip-dw-large   |   6 +
 .../fate/exr-rgb-scanline-half-zip-dw-outside |   6 +
 .../fate/exr-rgb-scanline-uint32-piz-dw-large |   6 +
 tests/ref/fate/exr-rgb-tile-half-piz-dw-large |   6 +
 tests/ref/fate/exr-rgb-tile-half-zip  |   6 +
 .../ref/fate/exr-rgb-tile-half-zip-dw-outside |   6 +
 .../ref/fate/exr-rgb-tile-uint32-piz-dw-large |   6 +
 tests/ref/fate/exr-ya-scanline-zip-half-12x8  |   6 +
 12 files changed, 155 insertions(+), 46 deletions(-)
 create mode 100644 tests/ref/fate/exr-rgb-scanline-float-zip-dw-large
 create mode 100644 tests/ref/fate/exr-rgb-scanline-half-piz-dw-large
 create mode 100644 tests/ref/fate/exr-rgb-scanline-half-zip-dw-large
 create mode 100644 tests/ref/fate/exr-rgb-scanline-half-zip-dw-outside
 create mode 100644 tests/ref/fate/exr-rgb-scanline-uint32-piz-dw-large
 create mode 100644 tests/ref/fate/exr-rgb-tile-half-piz-dw-large
 create mode 100644 tests/ref/fate/exr-rgb-tile-half-zip
 create mode 100644 tests/ref/fate/exr-rgb-tile-half-zip-dw-outside
 create mode 100644 tests/ref/fate/exr-rgb-tile-uint32-piz-dw-large
 create mode 100644 tests/ref/fate/exr-ya-scanline-zip-half-12x8

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 68d5befa40..d5f12cb22a 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -134,8 +134,8 @@ typedef struct EXRContext {
 const AVPixFmtDescriptor *desc;
 
 int w, h;
-uint32_t xmax, xmin;
-uint32_t ymax, ymin;
+int32_t xmax, xmin;
+int32_t ymax, ymin;
 uint32_t xdelta, ydelta;
 
 int scan_lines_per_block;
@@ -995,12 +995,13 @@ static int decode_block(AVCodecContext *avctx, void 
*tdata,
 uint64_t line_offset, uncompressed_size;
 uint8_t *ptr;
 uint32_t data_size;
-uint64_t line, col = 0;
+int line, col = 0;
 uint64_t tile_x, tile_y, tile_level_x, tile_level_y;
 const uint8_t *src;
 int step = s->desc->flags & AV_PIX_FMT_FLAG_FLOAT ? 4 : 2 * 
s->desc->nb_components;
-int axmax = (avctx->width - (s->xmax + 1)) * step; /* nb pixel to add at 
the right of the datawindow */
-int bxmin = s->xmin * step; /* nb pixel to add at the left of the 
datawindow */
+int bxmin, axmax, window_xoffset = 0;
+int window_xmin, window_xmax, window_ymin, window_ymax;
+int data_xoffset, data_yoffset, data_window_offset, xsize, ysize;
 int i, x, buf_size = s->buf_size;
 int c, rgb_channel_count;
 float one_gamma = 1.0f / s->gamma;
@@ -1029,28 +1030,16 @@ static int decode_block(AVCodecContext *avctx, void 
*tdata,
 return AVERROR_PATCHWELCOME;
 }
 
-if (s->xmin || s->ymin) {
-avpriv_report_missing_feature(s->avctx, "Tiles with xmin/ymin");
-return AVERROR_PATCHWELCOME;
-}
-
-line = s->tile_attr.ySize * tile_y;
+line = s->ymin + s->tile_attr.ySize * tile_y;
 col = s->tile_attr.xSize * tile_x;
 
 if (line < s->ymin || line > s->ymax ||
-col  < s->xmin || col  > s->xmax)
+s->xmin + col  < s->xmin ||  s->xmin + col  > s->xmax)
 return AVERROR_INVALIDDATA;
 
 td->ysize = FFMIN(s->tile_attr.ySize, s->ydelta - tile_y * 
s->tile_attr.ySize);
 td->xsize = FFMIN(s->tile_attr.xSize, s->xdelta - tile_x * 
s->tile_attr.xSize);
 
-if (col) { /* not the first tile of the line */
-bxmin = 0; /* doesn't add pixel at the left of the datawindow */
-}
-
-if ((col + td->xsize) != s->xdelta)/* not the last tile of the line */
-axmax = 0; /* doesn't add pixel at the right of the datawindow */
-
 td->channel_line_size = td->xsize * s->current_channel_offset;/* 
uncompress size of one line */
 uncompressed_size = td->channel_line_size * (uint64_t)td->ysize;/* 
uncompress size of the block */
 } else {
@@ -1081,6 +1070,33 @@ static int decode_block(AVCodecContext *avctx, void 
*tdata,
 }
 }
 
+window_xmin = FFMIN(avctx->width, FFMAX(0, s->xmin + col));
+window_xmax = FFMIN(avctx->width, FFMAX(0, s->xmin + col + td->xsize));
+window_ymin = FFMIN(avctx->height, FFMAX(0, line ));
+window_ymax = FFMIN(avctx->height, FFMAX(0, line + td->ysize));
+xsize = window_xmax - window_xmin;
+ysize = window_ymax - window_ymin;
+
+/* tile or scanline not visible skip decoding */
+if (xsize <= 0 || ysize <= 0)
+return 0;
+
+/* i