Rework temporal delimiter placement

Rework the OBU temporal delimiter in ducky_encode and make it match
the conventional behavior.

BUG=b/240265151

Change-Id: I2234d5060556ae24e15186005b2b5f2b1aae4625
diff --git a/av1/ducky_encode.cc b/av1/ducky_encode.cc
index 204e68c..70de54c 100644
--- a/av1/ducky_encode.cc
+++ b/av1/ducky_encode.cc
@@ -279,6 +279,7 @@
   impl_ptr_->enc_resource = InitEncoder(
       impl_ptr_->video_info, impl_ptr_->g_usage, impl_ptr_->rc_end_usage, pass,
       &stats_list, impl_ptr_->max_ref_frames, impl_ptr_->speed);
+  write_temp_delimiter_ = true;
 }
 
 static void DuckyEncodeInfoSetGopStruct(AV1_PRIMARY *ppi,
@@ -428,6 +429,7 @@
     const GopStructList &gop_list) {
   std::vector<TplGopStats> tpl_gop_stats_list;
   AV1_PRIMARY *ppi = impl_ptr_->enc_resource.ppi;
+  write_temp_delimiter_ = true;
 
   // Go through each gop and encode each frame in the gop
   for (size_t i = 0; i < gop_list.size(); ++i) {
@@ -442,6 +444,7 @@
                                                   { 128, -1 } };
       (void)frame;
       EncodeFrame(frame_decision);
+      write_temp_delimiter_ = ppi->cpi->common.show_frame;
     }
     tpl_gop_stats = ObtainTplStats(gop_struct);
     // TODO(jingning): Set the tpl stats file format and populate the stats.
@@ -457,6 +460,7 @@
     const GopEncodeInfoList &gop_encode_info_list) {
   AV1_PRIMARY *ppi = impl_ptr_->enc_resource.ppi;
   std::vector<EncodeFrameResult> encoded_frame_list;
+  write_temp_delimiter_ = true;
   // Go through each gop and encode each frame in the gop
   for (size_t i = 0; i < gop_list.size(); ++i) {
     const aom::GopStruct &gop_struct = gop_list[i];
@@ -468,6 +472,7 @@
                                                   aom::EncodeGopMode::kGopRcl,
                                                   frame_param };
       encoded_frame_list.push_back(EncodeFrame(frame_decision));
+      write_temp_delimiter_ = ppi->cpi->common.show_frame;
     }
   }
 
@@ -521,7 +526,7 @@
   DuckyEncodeInfoSetEncodeFrameDecision(&cpi->ducky_encode_info, decision);
   const int status = av1_get_compressed_data(cpi, &cpi_data);
 
-  if (cpi->common.show_frame) WriteObu(ppi, &cpi_data);
+  if (write_temp_delimiter_) WriteObu(ppi, &cpi_data);
   (void)status;
   assert(status == static_cast<int>(AOM_CODEC_OK));
   encode_frame_result.bitstream_buf.resize(cpi_data.frame_size);
diff --git a/av1/ducky_encode.h b/av1/ducky_encode.h
index fb36e37..1acb31f 100644
--- a/av1/ducky_encode.h
+++ b/av1/ducky_encode.h
@@ -87,6 +87,7 @@
  private:
   class EncodeImpl;
   std::unique_ptr<EncodeImpl> impl_ptr_;
+  bool write_temp_delimiter_;
 };
 }  // namespace aom