Re: [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_vp9: keep track of reference frames

2018-10-26 Thread Michael Niedermayer
On Fri, Oct 26, 2018 at 04:37:07PM -0300, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavcodec/cbs_vp9.h | 15 +-
>  libavcodec/cbs_vp9_syntax_template.c | 42 
>  2 files changed, 51 insertions(+), 6 deletions(-)

this breaks fate

--- ./tests/ref/fate/cbs-vp9-vp90-2-05-resize   2018-10-25 01:58:06.857005980 
+0200
+++ tests/data/fate/cbs-vp9-vp90-2-05-resize2018-10-26 23:02:53.528424915 
+0200
@@ -1 +1 @@
-6838422ebb45df353a2bad62b9aff8e9
+b3f142c27ba8cc205324d626af3a0a60
Test cbs-vp9-vp90-2-05-resize failed. Look at 
tests/data/fate/cbs-vp9-vp90-2-05-resize.err for details.
make: *** [fate-cbs-vp9-vp90-2-05-resize] Error 1

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] avcodec/cbs_vp9: keep track of reference frames

2018-10-26 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/cbs_vp9.h | 15 +-
 libavcodec/cbs_vp9_syntax_template.c | 42 
 2 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/libavcodec/cbs_vp9.h b/libavcodec/cbs_vp9.h
index 5b99c90c2e..47c3052c7d 100644
--- a/libavcodec/cbs_vp9.h
+++ b/libavcodec/cbs_vp9.h
@@ -117,7 +117,7 @@ typedef struct VP9RawFrameHeader {
 uint8_t frame_context_idx;
 
 // Frame/render size.
-uint8_t found_ref[VP9_REFS_PER_FRAME];
+uint8_t found_ref;
 uint16_t frame_width_minus_1;
 uint16_t frame_height_minus_1;
 uint8_t render_and_frame_size_different;
@@ -183,6 +183,13 @@ typedef struct VP9RawSuperframe {
 VP9RawSuperframeIndex index;
 } VP9RawSuperframe;
 
+typedef struct VP9ReferenceFrameState {
+int frame_width;// RefFrameWidth
+int frame_height;   // RefFrameHeight
+int subsampling_x;  // RefSubsamplingX
+int subsampling_y;  // RefSubsamplingY
+int bit_depth;  // RefBitDepth
+} VP9ReferenceFrameState;
 
 typedef struct CodedBitstreamVP9Context {
 // Frame dimensions in 8x8 mode info blocks.
@@ -192,6 +199,12 @@ typedef struct CodedBitstreamVP9Context {
 uint16_t sb64_cols;
 uint16_t sb64_rows;
 
+int bit_depth;
+int frame_width;
+int frame_height;
+
+VP9ReferenceFrameState ref[VP9_NUM_REF_FRAMES];
+
 // Write buffer.
 uint8_t *write_buffer;
 size_t write_buffer_size;
diff --git a/libavcodec/cbs_vp9_syntax_template.c 
b/libavcodec/cbs_vp9_syntax_template.c
index b4a7f65e85..b6209d979b 100644
--- a/libavcodec/cbs_vp9_syntax_template.c
+++ b/libavcodec/cbs_vp9_syntax_template.c
@@ -43,10 +43,14 @@ static int FUNC(frame_sync_code)(CodedBitstreamContext 
*ctx, RWContext *rw,
 static int FUNC(color_config)(CodedBitstreamContext *ctx, RWContext *rw,
   VP9RawFrameHeader *current, int profile)
 {
+CodedBitstreamVP9Context *vp9 = ctx->priv_data;
 int err;
 
-if (profile >= 2)
+if (profile >= 2) {
 f(1, ten_or_twelve_bit);
+vp9->bit_depth = current->ten_or_twelve_bit ? 12 : 10;
+} else
+vp9->bit_depth = 8;
 
 f(3, color_space);
 
@@ -81,8 +85,11 @@ static int FUNC(frame_size)(CodedBitstreamContext *ctx, 
RWContext *rw,
 f(16, frame_width_minus_1);
 f(16, frame_height_minus_1);
 
-vp9->mi_cols = (current->frame_width_minus_1  + 8) >> 3;
-vp9->mi_rows = (current->frame_height_minus_1 + 8) >> 3;
+vp9->frame_width  = current->frame_width_minus_1  + 1;
+vp9->frame_height = current->frame_height_minus_1 + 1;
+
+vp9->mi_cols = (vp9->frame_width  + 7) >> 3;
+vp9->mi_rows = (vp9->frame_height + 7) >> 3;
 vp9->sb64_cols = (vp9->mi_cols + 7) >> 3;
 vp9->sb64_rows = (vp9->mi_rows + 7) >> 3;
 
@@ -107,12 +114,24 @@ static int FUNC(render_size)(CodedBitstreamContext *ctx, 
RWContext *rw,
 static int FUNC(frame_size_with_refs)(CodedBitstreamContext *ctx, RWContext 
*rw,
   VP9RawFrameHeader *current)
 {
+CodedBitstreamVP9Context *vp9 = ctx->priv_data;
 int err, i;
 
 for (i = 0; i < VP9_REFS_PER_FRAME; i++) {
-fs(1, found_ref[i], 1, i);
-if (current->found_ref[i])
+f(1, found_ref);
+if (current->found_ref) {
+VP9ReferenceFrameState *ref =
+>ref[current->ref_frame_idx[i]];
+
+vp9->frame_width  = ref->frame_width;
+vp9->frame_height = ref->frame_height;
+
+vp9->mi_cols = (vp9->frame_width  + 7) >> 3;
+vp9->mi_rows = (vp9->frame_height + 7) >> 3;
+vp9->sb64_cols = (vp9->mi_cols + 7) >> 3;
+vp9->sb64_rows = (vp9->mi_rows + 7) >> 3;
 break;
+}
 }
 if (i >= VP9_REFS_PER_FRAME)
 CHECK(FUNC(frame_size)(ctx, rw, current));
@@ -249,6 +268,7 @@ static int FUNC(tile_info)(CodedBitstreamContext *ctx, 
RWContext *rw,
 static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
  VP9RawFrameHeader *current)
 {
+CodedBitstreamVP9Context *vp9 = ctx->priv_data;
 int profile, i;
 int err;
 
@@ -339,6 +359,18 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext 
*ctx, RWContext *rw,
 
 f(16, header_size_in_bytes);
 
+for (i = 0; i < VP9_NUM_REF_FRAMES; i++) {
+if (current->refresh_frame_flags & (1 << i)) {
+vp9->ref[i] = (VP9ReferenceFrameState) {
+.frame_width= vp9->frame_width,
+.frame_height   = vp9->frame_height,
+.subsampling_x  = current->subsampling_x,
+.subsampling_y  = current->subsampling_y,
+.bit_depth  = vp9->bit_depth,
+};
+}
+}
+
 return 0;
 }
 
-- 
2.19.0

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