]> granicus.if.org Git - libvpx/commitdiff
Add frame info in bitstream debug tool
authorAngie Chiang <angiebird@google.com>
Thu, 1 Sep 2016 23:10:50 +0000 (16:10 -0700)
committerAngie Chiang <angiebird@google.com>
Thu, 1 Sep 2016 23:24:49 +0000 (16:24 -0700)
Change-Id: Iead3edd8563d7900481eb199e8b003d2d3df075b

aom_dsp/bitreader.h
aom_dsp/bitwriter.h
aom_util/debug_util.c
aom_util/debug_util.h
av1/decoder/decodeframe.c
av1/encoder/encoder.c

index 402461d02b2bf641dde2f459a734dd485c76fe82..1b34aa2c316cacc43ab9af548a28ba7fc1902b4a 100644 (file)
@@ -114,14 +114,18 @@ static INLINE int aom_read(aom_reader *r, int prob) {
   {
     int ref_bit, ref_prob;
     const int queue_r = bitstream_queue_get_read();
+    const int frame_idx = bitstream_queue_get_frame_read();
     bitstream_queue_pop(&ref_bit, &ref_prob);
     if (prob != ref_prob) {
-      fprintf(stderr, "prob error, prob %d ref_prob %d queue_r %d\n", prob,
-              ref_prob, queue_r);
+      fprintf(
+          stderr,
+          "\n *** prob error, frame_idx_r %d prob %d ref_prob %d queue_r %d\n",
+          frame_idx, prob, ref_prob, queue_r);
       assert(0);
     }
     if ((int)bit != ref_bit) {
-      fprintf(stderr, "bit error, bit %d ref_bit %d\n", bit, ref_bit);
+      fprintf(stderr, "\n *** bit error, frame_idx_r %d bit %d ref_bit %d\n",
+              frame_idx, bit, ref_bit);
       assert(0);
     }
   }
index c6bc99baefa90ab947a9e69d52915157c235d646..d68bbb7aafce331eda306a98f5f7c23406018a31 100644 (file)
 #ifndef AOM_DSP_BITWRITER_H_
 #define AOM_DSP_BITWRITER_H_
 
+#include "./aom_config.h"
+
+#if CONFIG_BITSTREAM_DEBUG
+#include <stdio.h>
+#endif
+
 #include "aom_ports/mem.h"
 #include "aom_dsp/prob.h"
 #include "aom_util/debug_util.h"
@@ -38,6 +44,14 @@ static INLINE void aom_write(aom_writer *br, int bit, int probability) {
   register int shift;
 
 #if CONFIG_BITSTREAM_DEBUG
+  // int queue_r = 0;
+  // int frame_idx_r = 0;
+  // int queue_w = bitstream_queue_get_write();
+  // int frame_idx_w = bitstream_queue_get_frame_write();
+  // if (frame_idx_w == frame_idx_r && queue_w == queue_r) {
+  //   fprintf(stderr, "\n *** bitstream queue at frame_idx_w %d queue_w %d\n",
+  //   frame_idx_w, queue_w);
+  // }
   bitstream_queue_push(bit, probability);
 #endif  // CONFIG_BITSTREAM_DEBUG
 
index 5fe88db309908a8d2dfb9e80f7d309cbc184108e..ca666a1cc2d283dbefef532f58901c7aa488e28e 100644 (file)
@@ -21,6 +21,18 @@ static int queue_prev_w = -1;
 static int skip_r = 0;
 static int skip_w = 0;
 
+static int frame_idx_w = 0;
+
+static int frame_idx_r = 0;
+
+void bitstream_queue_set_frame_write(int frame_idx) { frame_idx_w = frame_idx; }
+
+int bitstream_queue_get_frame_write() { return frame_idx_w; }
+
+void bitstream_queue_set_frame_read(int frame_idx) { frame_idx_r = frame_idx; }
+
+int bitstream_queue_get_frame_read() { return frame_idx_r; }
+
 void bitstream_queue_set_skip_write(int skip) { skip_w = skip; }
 
 void bitstream_queue_set_skip_read(int skip) { skip_r = skip; }
index aa6896cba8cb29a92c9f6ec003e83f52080cd519..5cad87ca4d1488f1d298c7d7a6422f628899ec5c 100644 (file)
@@ -34,6 +34,10 @@ void bitstream_queue_pop(int *result, int *prob);
 void bitstream_queue_push(int result, int prob);
 void bitstream_queue_set_skip_write(int skip);
 void bitstream_queue_set_skip_read(int skip);
+void bitstream_queue_set_frame_write(int frame_idx);
+int bitstream_queue_get_frame_write();
+void bitstream_queue_set_frame_read(int frame_idx);
+int bitstream_queue_get_frame_read();
 #endif  // CONFIG_BITSTREAM_DEBUG
 
 #ifdef __cplusplus
index 638fa01f5c1ee4bb0d587ca716836b0920ebcf91..8e64ac5f7cccbe0609d2511d6a392dbdff074e26 100644 (file)
@@ -3724,9 +3724,16 @@ void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data,
   struct aom_read_bit_buffer rb;
   int context_updated = 0;
   uint8_t clear_data[MAX_AV1_HEADER_SIZE];
-  const size_t first_partition_size = read_uncompressed_header(
+  size_t first_partition_size;
+  YV12_BUFFER_CONFIG *new_fb;
+
+#if CONFIG_BITSTREAM_DEBUG
+  bitstream_queue_set_frame_read(cm->current_video_frame * 2 + cm->show_frame);
+#endif
+
+  first_partition_size = read_uncompressed_header(
       pbi, init_read_bit_buffer(pbi, &rb, data, data_end, clear_data));
-  YV12_BUFFER_CONFIG *const new_fb = get_frame_new_buffer(cm);
+  new_fb = get_frame_new_buffer(cm);
   xd->cur_buf = new_fb;
 #if CONFIG_GLOBAL_MOTION
   xd->global_motion = cm->global_motion;
index 619204d856bd7f81dd4787b93c29a54bd0d48bae..c2e827551191816c23b2e000b6d8e31f30795c55 100644 (file)
@@ -5198,6 +5198,7 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
   assert(cpi->oxcf.max_threads == 0 &&
          "bitstream debug tool does not support multithreading");
   bitstream_queue_record_write();
+  bitstream_queue_set_frame_write(cm->current_video_frame * 2 + cm->show_frame);
 #endif
 
   aom_usec_timer_start(&cmptimer);