[libav-devel] [PATCH 09/11] avconv: rescue poor abused recording_time global.

2011-08-17 Thread Anton Khirnov
Keep a per-OutputFile instance of it, thus making -t work with multiple
output files.
---
 avconv.c   |   22 ++--
 tests/ref/fate/feeble-dxa  |1 -
 tests/ref/fate/lmlm4-demux |  332 
 tests/ref/fate/real-rv40   |3 +
 4 files changed, 16 insertions(+), 342 deletions(-)

diff --git a/avconv.c b/avconv.c
index 8b92158..4979815 100644
--- a/avconv.c
+++ b/avconv.c
@@ -272,6 +272,7 @@ typedef struct OutputStream {
 
int sws_flags;
AVDictionary *opts;
+   int is_past_recording_time;
 } OutputStream;
 
 typedef struct InputStream {
@@ -289,7 +290,6 @@ typedef struct InputStream {
 double ts_scale;
 int is_start;/* is 1 at the start and after a discontinuity */
 int showed_multi_packet_warning;
-int is_past_recording_time;
 AVDictionary *opts;
 } InputStream;
 
@@ -305,6 +305,7 @@ typedef struct OutputFile {
 AVFormatContext *ctx;
 AVDictionary *opts;
 int ost_index;   /* index of the first stream in output_streams */
+int64_t recording_time; /* desired length of the resulting file in 
microseconds */
 } OutputFile;
 
 static InputStream *input_streams = NULL;
@@ -1563,12 +1564,20 @@ static int output_packet(InputStream *ist, int 
ist_index,
encode packets and output them */
 if (start_time == 0 || ist-pts = start_time)
 for(i=0;inb_ostreams;i++) {
+OutputFile *of = output_files[ost_table[i].file_index];
 int frame_size;
 
 ost = ost_table[i];
 if (ost-source_index != ist_index)
 continue;
 
+if (of-recording_time != INT64_MAX 
+av_compare_ts(ist-pts, AV_TIME_BASE_Q, of-recording_time 
+ start_time,
+  (AVRational){1, 100}) = 0) {
+ost-is_past_recording_time = 1;
+continue;
+}
+
 #if CONFIG_AVFILTER
 if (ist-st-codec-codec_type == AVMEDIA_TYPE_VIDEO 
 ost-input_video_filter) {
@@ -2220,7 +2229,7 @@ static int transcode(OutputFile *output_files,
 ost = output_streams[i];
 os = output_files[ost-file_index].ctx;
 ist = input_streams[ost-source_index];
-if(ist-is_past_recording_time || no_packet[ist-file_index])
+if(ost-is_past_recording_time || no_packet[ist-file_index])
 continue;
 opts = ost-st-pts.val * av_q2d(ost-st-time_base);
 ipts = (double)ist-pts;
@@ -2314,13 +2323,6 @@ static int transcode(OutputFile *output_files,
 }
 }
 
-/* finish if recording time exhausted */
-if (recording_time != INT64_MAX 
-av_compare_ts(pkt.pts, ist-st-time_base, recording_time + 
start_time, (AVRational){1, 100}) = 0) {
-ist-is_past_recording_time = 1;
-goto discard_packet;
-}
-
 //fprintf(stderr,read #%d.%d size=%d\n, ist-file_index, 
ist-st-index, pkt.size);
 if (output_packet(ist, ist_index, output_streams, nb_output_streams, 
pkt)  0) {
 
@@ -3544,6 +3546,7 @@ static void opt_output_file(const char *filename)
 output_files = grow_array(output_files, sizeof(*output_files), 
nb_output_files, nb_output_files + 1);
 output_files[nb_output_files - 1].ctx   = oc;
 output_files[nb_output_files - 1].ost_index = nb_output_streams - 
oc-nb_streams;
+output_files[nb_output_files - 1].recording_time = recording_time;
 av_dict_copy(output_files[nb_output_files - 1].opts, format_opts, 0);
 
 /* check filename in case of an image number is expected */
@@ -3669,6 +3672,7 @@ static void opt_output_file(const char *filename)
 audio_channels= 0;
 audio_sample_fmt  = AV_SAMPLE_FMT_NONE;
 chapters_input_file = INT_MAX;
+recording_time = INT64_MAX;
 
 av_freep(meta_data_maps);
 nb_meta_data_maps = 0;
diff --git a/tests/ref/fate/feeble-dxa b/tests/ref/fate/feeble-dxa
index 9013f99..caea4c2 100644
--- a/tests/ref/fate/feeble-dxa
+++ b/tests/ref/fate/feeble-dxa
@@ -62,4 +62,3 @@
 0, 171000, 921600, 0x5639e670
 1, 171429, 1000, 0xa491f3ef
 1, 175510, 1000, 0x2c036e18
-1, 179592, 1000, 0x52d65e2a
diff --git a/tests/ref/fate/lmlm4-demux b/tests/ref/fate/lmlm4-demux
index f322300..f321423 100644
--- a/tests/ref/fate/lmlm4-demux
+++ b/tests/ref/fate/lmlm4-demux
@@ -213,335 +213,3 @@
 1, 265680, 768, 0xfd6c7597
 0, 267267, 1327, 0x7d15307c
 1, 267840, 768, 0x8d766d40
-0, 270270, 1225, 0x1b5d0f5f
-0, 273273, 1173, 0x840efed5
-0, 276276, 1215, 0xa8e0035e
-0, 279279, 1295, 0x142918ca
-0, 282282, 1144, 0xf50cef50
-0, 285285, 1527, 0x7d13bd9d
-0, 288288, 5609, 0x1ae1921d
-0, 291291, 1303, 0xabdc264f
-0, 294294, 1419, 0x878169bf
-0, 297297, 972, 0x00c4a257
-0, 300300, 1277, 0x87d520cf
-0, 303303, 1014, 0x5946b4ee
-0, 306306, 1177, 0x124e0e23
-0, 309309, 1402, 0x8e6363cc
-0, 312312, 1171, 0x9bdaeda2
-0, 

Re: [libav-devel] [PATCH 09/11] avconv: rescue poor abused recording_time global.

2011-08-17 Thread Kostya
On Wed, Aug 17, 2011 at 05:04:50PM +0200, Anton Khirnov wrote:
 Keep a per-OutputFile instance of it, thus making -t work with multiple
 output files.
 ---
  avconv.c   |   22 ++--
  tests/ref/fate/feeble-dxa  |1 -
  tests/ref/fate/lmlm4-demux |  332 
 
  tests/ref/fate/real-rv40   |3 +
  4 files changed, 16 insertions(+), 342 deletions(-)

looks OK (especially if you have found out and can explain the reason why
those fate test changed).
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 09/11] avconv: rescue poor abused recording_time global.

2011-08-17 Thread Anton Khirnov

On Wed, 17 Aug 2011 18:01:58 +0200, Kostya kostya.shish...@gmail.com wrote:
 On Wed, Aug 17, 2011 at 05:04:50PM +0200, Anton Khirnov wrote:
  Keep a per-OutputFile instance of it, thus making -t work with multiple
  output files.
  ---
   avconv.c   |   22 ++--
   tests/ref/fate/feeble-dxa  |1 -
   tests/ref/fate/lmlm4-demux |  332 
  
   tests/ref/fate/real-rv40   |3 +
   4 files changed, 16 insertions(+), 342 deletions(-)
 
 looks OK (especially if you have found out and can explain the reason why
 those fate test changed).

The big change in lmlm4 is a bug in current behavior -- it produces a
15s long video stream (and correct 3s long audio) even though -t 3 is
specified. After my patch the video is correctly 3 seconds long.

The other twono idea. Some magic inside output_packet() most
probably. I can try to investigate further if you feel it's important.

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 09/11] avconv: rescue poor abused recording_time global.

2011-08-17 Thread Kostya
On Wed, Aug 17, 2011 at 06:25:19PM +0200, Anton Khirnov wrote:
 
 On Wed, 17 Aug 2011 18:01:58 +0200, Kostya kostya.shish...@gmail.com wrote:
  On Wed, Aug 17, 2011 at 05:04:50PM +0200, Anton Khirnov wrote:
   Keep a per-OutputFile instance of it, thus making -t work with multiple
   output files.
   ---
avconv.c   |   22 ++--
tests/ref/fate/feeble-dxa  |1 -
tests/ref/fate/lmlm4-demux |  332 
   
tests/ref/fate/real-rv40   |3 +
4 files changed, 16 insertions(+), 342 deletions(-)
  
  looks OK (especially if you have found out and can explain the reason why
  those fate test changed).
 
 The big change in lmlm4 is a bug in current behavior -- it produces a
 15s long video stream (and correct 3s long audio) even though -t 3 is
 specified. After my patch the video is correctly 3 seconds long.
 
 The other twono idea. Some magic inside output_packet() most
 probably. I can try to investigate further if you feel it's important.

No, that's enough for me.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel