From c86dacb6521dc922ba4ad5ecb0a125cefe9e824e Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <randrianasulu@gmail.com>
Date: Mon, 7 Nov 2022 20:20:57 +0300
Subject: [PATCH 2/2] TEST better field probe in bdwrite

---
 cinelerra-5.1/cinelerra/bdwrite.C | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/cinelerra-5.1/cinelerra/bdwrite.C b/cinelerra-5.1/cinelerra/bdwrite.C
index 813d0332..9d106467 100644
--- a/cinelerra-5.1/cinelerra/bdwrite.C
+++ b/cinelerra-5.1/cinelerra/bdwrite.C
@@ -2576,9 +2576,19 @@ static int field_probe(AVFormatContext *fmt_ctx, AVStream *st)
   av_frame_free(&ipic);
   avcodec_free_context(&ctx);
   
-  if (ilaced < 0){ 
-  ilaced = st->codecpar->field_order;
-  fprintf(stderr, "warning bdwrite uses field into from stream \n", ilaced);
+  if (ilaced < 0) {
+  fprintf(stderr, "warning bdwrite uses field into from stream \n", st->codecpar->field_order);
+  switch(st->codecpar->field_order) {
+  case AV_FIELD_TT:
+  case AV_FIELD_TB:   
+  case AV_FIELD_BB:    
+  case AV_FIELD_BT:      
+     return 1;
+  case AV_FIELD_PROGRESSIVE:   
+    return 0;
+  default:
+   return -1;
+   }
   }
   
   
-- 
2.38.1

