diff mbox

[FFmpeg-devel,1/2] avformat: add av_stream_get_codec_timebase()

Message ID 20160926173913.976-1-jamrial@gmail.com
State Accepted, archived
Headers show

Commit Message

James Almer Sept. 26, 2016, 5:39 p.m. UTC
This will allow ffmpeg.c to stop using AVStream.codec in some cases

Signed-off-by: James Almer <jamrial@gmail.com>
---
TODO: Version bump, APIChanges entry.

 libavformat/avformat.h |  7 +++++++
 libavformat/utils.c    | 10 ++++++++++
 2 files changed, 17 insertions(+)

Comments

wm4 Sept. 26, 2016, 6:22 p.m. UTC | #1
On Mon, 26 Sep 2016 14:39:12 -0300
James Almer <jamrial@gmail.com> wrote:

> This will allow ffmpeg.c to stop using AVStream.codec in some cases
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> TODO: Version bump, APIChanges entry.
> 
>  libavformat/avformat.h |  7 +++++++
>  libavformat/utils.c    | 10 ++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index ae70cc8..057f8c5 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -2922,6 +2922,13 @@ int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
>                                                    enum AVTimebaseSource copy_tb);
>  
>  /**
> + * Get the internal codec timebase from a stream.
> + *
> + * @param st  input stream to extract the timebase from
> + */
> +AVRational av_stream_get_codec_timebase(const AVStream *st);
> +
> +/**
>   * @}
>   */
>  
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 3e0f57d..abb5fb9 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -5383,3 +5383,13 @@ int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
>  
>      return 0;
>  }
> +
> +AVRational av_stream_get_codec_timebase(const AVStream *st)
> +{
> +    // See avformat_transfer_internal_stream_timing_info() TODO.
> +#if FF_API_LAVF_AVCTX
> +FF_DISABLE_DEPRECATION_WARNINGS
> +    return st->codec->time_base;
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif
> +}

So if FF_API_LAVF_AVCTX is finally removed, this function changes its
behavior to launching nethack? I don't get it.
James Almer Sept. 26, 2016, 6:45 p.m. UTC | #2
On 9/26/2016 3:22 PM, wm4 wrote:
> On Mon, 26 Sep 2016 14:39:12 -0300
> James Almer <jamrial@gmail.com> wrote:
> 
>> This will allow ffmpeg.c to stop using AVStream.codec in some cases
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>> TODO: Version bump, APIChanges entry.
>>
>>  libavformat/avformat.h |  7 +++++++
>>  libavformat/utils.c    | 10 ++++++++++
>>  2 files changed, 17 insertions(+)
>>
>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>> index ae70cc8..057f8c5 100644
>> --- a/libavformat/avformat.h
>> +++ b/libavformat/avformat.h
>> @@ -2922,6 +2922,13 @@ int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
>>                                                    enum AVTimebaseSource copy_tb);
>>  
>>  /**
>> + * Get the internal codec timebase from a stream.
>> + *
>> + * @param st  input stream to extract the timebase from
>> + */
>> +AVRational av_stream_get_codec_timebase(const AVStream *st);
>> +
>> +/**
>>   * @}
>>   */
>>  
>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>> index 3e0f57d..abb5fb9 100644
>> --- a/libavformat/utils.c
>> +++ b/libavformat/utils.c
>> @@ -5383,3 +5383,13 @@ int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
>>  
>>      return 0;
>>  }
>> +
>> +AVRational av_stream_get_codec_timebase(const AVStream *st)
>> +{
>> +    // See avformat_transfer_internal_stream_timing_info() TODO.
>> +#if FF_API_LAVF_AVCTX
>> +FF_DISABLE_DEPRECATION_WARNINGS
>> +    return st->codec->time_base;
>> +FF_ENABLE_DEPRECATION_WARNINGS
>> +#endif
>> +}
> 
> So if FF_API_LAVF_AVCTX is finally removed, this function changes its
> behavior to launching nethack? I don't get it.

That's why i added the comment about seeing the
avformat_transfer_internal_stream_timing_info() TODO. It should use
st->internal->avctx when that happens, much like the other function.

I can add that inside an #else if you prefer, but many other things
would break without further changes as soon as AVStream.codec is
gone beside this function anyway, like for example the one with the
TODO in question.
diff mbox

Patch

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index ae70cc8..057f8c5 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2922,6 +2922,13 @@  int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
                                                   enum AVTimebaseSource copy_tb);
 
 /**
+ * Get the internal codec timebase from a stream.
+ *
+ * @param st  input stream to extract the timebase from
+ */
+AVRational av_stream_get_codec_timebase(const AVStream *st);
+
+/**
  * @}
  */
 
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 3e0f57d..abb5fb9 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -5383,3 +5383,13 @@  int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
 
     return 0;
 }
+
+AVRational av_stream_get_codec_timebase(const AVStream *st)
+{
+    // See avformat_transfer_internal_stream_timing_info() TODO.
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+    return st->codec->time_base;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+}