Re: [FFmpeg-devel] [PATCH 2/2] tests/api/api-h264-test: Add AV_NOPTS_VALUE check for AVFrame.pkt_dts

2019-02-10 Thread Michael Niedermayer
On Sun, Feb 10, 2019 at 02:53:58PM +0800, Jun Zhao wrote:
> Add AV_NOPTS_VALUE check for AVFrame.pkt_dts to avoid print the
> pkt_dts as negative number like:
> "0,3616613, -9223372036854775808, 1001,  3110400, 0x75e37a65"
> 
> Signed-off-by: Jun Zhao 
> ---
>  tests/api/api-h264-test.c |   12 +---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c
> index 9fa..351d622 100644
> --- a/tests/api/api-h264-test.c
> +++ b/tests/api/api-h264-test.c
> @@ -131,9 +131,15 @@ static int video_decode_example(const char 
> *input_filename)
>  av_log(NULL, AV_LOG_ERROR, "Can't copy image to 
> buffer\n");
>  return number_of_written_bytes;
>  }
> -printf("%d, %10"PRId64", %10"PRId64", %8"PRId64", %8d, 
> 0x%08lx\n", video_stream,
> -fr->pts, fr->pkt_dts, fr->pkt_duration,
> -number_of_written_bytes, av_adler32_update(0, (const 
> uint8_t*)byte_buffer, number_of_written_bytes));
> +
> +if (fr->pkt_dts == AV_NOPTS_VALUE)
> +printf("%d, %10"PRId64", %s, %8"PRId64", %8d, 
> 0x%08lx\n", video_stream,
> +   fr->pts, "N/A", fr->pkt_duration,
> +   number_of_written_bytes, av_adler32_update(0, 
> (const uint8_t*)byte_buffer, number_of_written_bytes));
> +else
> +printf("%d, %10"PRId64", %10"PRId64", %8"PRId64", %8d, 
> 0x%08lx\n", video_stream,
> +   fr->pts, fr->pkt_dts, fr->pkt_duration,
> +   number_of_written_bytes, av_adler32_update(0, 
> (const uint8_t*)byte_buffer, number_of_written_bytes));

you can split the printf() in 2 so the common parts are not duplicated

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The smallest minority on earth is the individual. Those who deny 
individual rights cannot claim to be defenders of minorities. - Ayn Rand


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] tests/api/api-h264-test: Add AV_NOPTS_VALUE check for AVFrame.pkt_dts

2019-02-09 Thread Jun Zhao
Add AV_NOPTS_VALUE check for AVFrame.pkt_dts to avoid print the
pkt_dts as negative number like:
"0,3616613, -9223372036854775808, 1001,  3110400, 0x75e37a65"

Signed-off-by: Jun Zhao 
---
 tests/api/api-h264-test.c |   12 +---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c
index 9fa..351d622 100644
--- a/tests/api/api-h264-test.c
+++ b/tests/api/api-h264-test.c
@@ -131,9 +131,15 @@ static int video_decode_example(const char *input_filename)
 av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n");
 return number_of_written_bytes;
 }
-printf("%d, %10"PRId64", %10"PRId64", %8"PRId64", %8d, 
0x%08lx\n", video_stream,
-fr->pts, fr->pkt_dts, fr->pkt_duration,
-number_of_written_bytes, av_adler32_update(0, (const 
uint8_t*)byte_buffer, number_of_written_bytes));
+
+if (fr->pkt_dts == AV_NOPTS_VALUE)
+printf("%d, %10"PRId64", %s, %8"PRId64", %8d, 0x%08lx\n", 
video_stream,
+   fr->pts, "N/A", fr->pkt_duration,
+   number_of_written_bytes, av_adler32_update(0, 
(const uint8_t*)byte_buffer, number_of_written_bytes));
+else
+printf("%d, %10"PRId64", %10"PRId64", %8"PRId64", %8d, 
0x%08lx\n", video_stream,
+   fr->pts, fr->pkt_dts, fr->pkt_duration,
+   number_of_written_bytes, av_adler32_update(0, 
(const uint8_t*)byte_buffer, number_of_written_bytes));
 }
 av_packet_unref(&pkt);
 av_init_packet(&pkt);
-- 
1.7.1

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