[FFmpeg-devel] lavc: Allow very high bitrates in AVCPBProperties after next version bump

Submitted by Carl Eugen Hoyos on Jan. 10, 2019, 9:27 p.m.

Details

Message ID CAB0OVGpEHWh9YWLhSAP8ZuXwD319=0oSP4bqqRyw0WMjkEAfrw@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos Jan. 10, 2019, 9:27 p.m.
Hi!

I don't know how urgent this is and how easily this can be triggered
with AVCPBProperties but we had issues with bitrates > INT32MAX in the
past, so looking at this code before realizing the qsv bitrate issue
is Intel-related I thought this patch cannot hurt.

Please comment, Carl Eugen

Comments

James Almer Jan. 11, 2019, 12:07 a.m.
On 1/10/2019 6:27 PM, Carl Eugen Hoyos wrote:
> Hi!
> 
> I don't know how urgent this is and how easily this can be triggered
> with AVCPBProperties but we had issues with bitrates > INT32MAX in the
> past, so looking at this code before realizing the qsv bitrate issue
> is Intel-related I thought this patch cannot hurt.
> 
> Please comment, Carl Eugen

Probalby correct. bitrate fields in AVCodecContext are all int64_t, and
AVCPBProperties fields are usually set to those.
Derek Buitenhuis Jan. 11, 2019, 1:09 p.m.
On 11/01/2019 00:07, James Almer wrote:
> Probalby correct. bitrate fields in AVCodecContext are all int64_t, and
> AVCPBProperties fields are usually set to those.

Only semi-related: Is it useful to properly clip the bitrate to INT_MAX/INT_MIN
where we set it currently (behind deprecation guards, of course), since the
behavior is implementation-defined, IIRC?

- Derek
Carl Eugen Hoyos Jan. 12, 2019, 4:34 p.m.
2019-01-11 1:07 GMT+01:00, James Almer <jamrial@gmail.com>:
> On 1/10/2019 6:27 PM, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> I don't know how urgent this is and how easily this can be triggered
>> with AVCPBProperties but we had issues with bitrates > INT32MAX in the
>> past, so looking at this code before realizing the qsv bitrate issue
>> is Intel-related I thought this patch cannot hurt.
>>
>> Please comment, Carl Eugen
>
> Probalby correct. bitrate fields in AVCodecContext are all int64_t, and
> AVCPBProperties fields are usually set to those.

Patch applied.

Thank you, Carl Eugen

Patch hide | download patch | download mbox

From 64af64cd883c7f6957ced8f24c50b5c5c4821f61 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Thu, 10 Jan 2019 22:23:39 +0100
Subject: [PATCH] lavc: Allow very high bitrates in AVCPBProperties after next
 version bump.

---
 libavcodec/avcodec.h |   12 ++++++++++++
 libavcodec/version.h |    3 +++
 2 files changed, 15 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 92567ec..4414853 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1118,17 +1118,29 @@  typedef struct AVCPBProperties {
      * Maximum bitrate of the stream, in bits per second.
      * Zero if unknown or unspecified.
      */
+#if FF_API_UNSANITIZED_BITRATES
     int max_bitrate;
+#else
+    int64_t max_bitrate;
+#endif
     /**
      * Minimum bitrate of the stream, in bits per second.
      * Zero if unknown or unspecified.
      */
+#if FF_API_UNSANITIZED_BITRATES
     int min_bitrate;
+#else
+    int64_t min_bitrate;
+#endif
     /**
      * Average bitrate of the stream, in bits per second.
      * Zero if unknown or unspecified.
      */
+#if FF_API_UNSANITIZED_BITRATES
     int avg_bitrate;
+#else
+    int64_t avg_bitrate;
+#endif
 
     /**
      * The size of the buffer to which the ratecontrol is applied, in bits.
diff --git a/libavcodec/version.h b/libavcodec/version.h
index ed56a1e..d2c0b31 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -132,6 +132,9 @@ 
 #ifndef FF_API_NEXT
 #define FF_API_NEXT              (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_UNSANITIZED_BITRATES
+#define FF_API_UNSANITIZED_BITRATES (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 
 
 #endif /* AVCODEC_VERSION_H */
-- 
1.7.10.4