diff mbox

[FFmpeg-devel,2/2] tools/uncoded_frame: remove usage of avfilter_link_get_channels()

Message ID 20180106133810.GA3283318@phare.normalesup.org
State New
Headers show

Commit Message

Nicolas George Jan. 6, 2018, 1:38 p.m. UTC
And while we're at it, let's fix a bunch of warnings.

Note that I (or somebody else) need to check if this is still relevant
with the "wrapped AVFrame" API from the fork, but that is another issue
entirely.

Regards,

Comments

James Almer Jan. 6, 2018, 2:06 p.m. UTC | #1
On 1/6/2018 10:38 AM, Nicolas George wrote:
> And while we're at it, let's fix a bunch of warnings.
> 
> Note that I (or somebody else) need to check if this is still relevant
> with the "wrapped AVFrame" API from the fork, but that is another issue
> entirely.
> 
> Regards,
> 
> -- Nicolas George
> 
> 
> 0001-tools-uncoded_frame-remove-use-of-AVStream.codec.patch
> 
> 
> From 7a3a21108fca8e039ae4d5623ae18f828dc23f5e Mon Sep 17 00:00:00 2001
> From: Nicolas George <george@nsup.org>
> Date: Sat, 6 Jan 2018 14:34:00 +0100
> Subject: [PATCH] tools/uncoded_frame: remove use of AVStream.codec.
> 
> Signed-off-by: Nicolas George <george@nsup.org>
> ---
>  tools/uncoded_frame.c | 28 +++++++++++++---------------
>  1 file changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/tools/uncoded_frame.c b/tools/uncoded_frame.c
> index f346b21916..606bdb746a 100644
> --- a/tools/uncoded_frame.c
> +++ b/tools/uncoded_frame.c
> @@ -161,26 +161,24 @@ int main(int argc, char **argv)
>              av_log(NULL, AV_LOG_ERROR, "Failed to create output stream\n");
>              goto fail;
>          }
> -        st->stream->codec->codec_type = av_buffersink_get_type(st->sink);
> -        st->stream->time_base = st->stream->codec->time_base =
> -            av_buffersink_get_time_base(st->sink);
> +        st->stream->codecpar->codec_type = av_buffersink_get_type(st->sink);
> +        st->stream->time_base = av_buffersink_get_time_base(st->sink);
>          switch (av_buffersink_get_type(st->sink)) {
>          case AVMEDIA_TYPE_VIDEO:
> -            st->stream->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
> +            st->stream->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
>              st->stream->avg_frame_rate =
>              st->stream->  r_frame_rate = av_buffersink_get_frame_rate(st->sink);
> -            st->stream->codec->width               = av_buffersink_get_w(st->sink);
> -            st->stream->codec->height              = av_buffersink_get_h(st->sink);
> -            st->stream->codec->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(st->sink);
> -            st->stream->codec->pix_fmt             = av_buffersink_get_format(st->sink);
> +            st->stream->codecpar->width               = av_buffersink_get_w(st->sink);
> +            st->stream->codecpar->height              = av_buffersink_get_h(st->sink);
> +            st->stream->codecpar->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(st->sink);
> +            st->stream->codecpar->format              = av_buffersink_get_format(st->sink);
>              break;
>          case AVMEDIA_TYPE_AUDIO:
> -            st->stream->codec->channel_layout = av_buffersink_get_channel_layout(st->sink);
> -            st->stream->codec->channels       = av_buffersink_get_channels(st->sink);
> -            st->stream->codec->sample_rate    = av_buffersink_get_sample_rate(st->sink);
> -            st->stream->codec->sample_fmt     = av_buffersink_get_format(st->sink);
> -            st->stream->codec->codec_id =
> -                av_get_pcm_codec(st->stream->codec->sample_fmt, -1);
> +            st->stream->codecpar->channel_layout = av_buffersink_get_channel_layout(st->sink);
> +            st->stream->codecpar->channels       = av_buffersink_get_channels(st->sink);
> +            st->stream->codecpar->sample_rate    = av_buffersink_get_sample_rate(st->sink);
> +            st->stream->codecpar->format         = av_buffersink_get_format(st->sink);
> +            st->stream->codecpar->codec_id       = av_get_pcm_codec(st->stream->codecpar->format, -1);
>              break;
>          default:
>              av_assert0(!"reached");
> @@ -245,7 +243,7 @@ int main(int argc, char **argv)
>                                                           frame);
>                  frame = NULL;
>                  if (ret < 0) {
> -                    av_log(st->stream->codec, AV_LOG_ERROR,
> +                    av_log(st->mux, AV_LOG_ERROR,
>                             "Error writing frame: %s\n", av_err2str(ret));
>                      goto fail;
>                  }
> -- 2.15.1

Both patches should be ok. Thanks.
Nicolas George Jan. 6, 2018, 2:12 p.m. UTC | #2
James Almer (2018-01-06):
> Both patches should be ok. Thanks.

Thanks, pushed.

Regards,
diff mbox

Patch

From 7a3a21108fca8e039ae4d5623ae18f828dc23f5e Mon Sep 17 00:00:00 2001
From: Nicolas George <george@nsup.org>
Date: Sat, 6 Jan 2018 14:34:00 +0100
Subject: [PATCH] tools/uncoded_frame: remove use of AVStream.codec.

Signed-off-by: Nicolas George <george@nsup.org>
---
 tools/uncoded_frame.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/tools/uncoded_frame.c b/tools/uncoded_frame.c
index f346b21916..606bdb746a 100644
--- a/tools/uncoded_frame.c
+++ b/tools/uncoded_frame.c
@@ -161,26 +161,24 @@  int main(int argc, char **argv)
             av_log(NULL, AV_LOG_ERROR, "Failed to create output stream\n");
             goto fail;
         }
-        st->stream->codec->codec_type = av_buffersink_get_type(st->sink);
-        st->stream->time_base = st->stream->codec->time_base =
-            av_buffersink_get_time_base(st->sink);
+        st->stream->codecpar->codec_type = av_buffersink_get_type(st->sink);
+        st->stream->time_base = av_buffersink_get_time_base(st->sink);
         switch (av_buffersink_get_type(st->sink)) {
         case AVMEDIA_TYPE_VIDEO:
-            st->stream->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
+            st->stream->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
             st->stream->avg_frame_rate =
             st->stream->  r_frame_rate = av_buffersink_get_frame_rate(st->sink);
-            st->stream->codec->width               = av_buffersink_get_w(st->sink);
-            st->stream->codec->height              = av_buffersink_get_h(st->sink);
-            st->stream->codec->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(st->sink);
-            st->stream->codec->pix_fmt             = av_buffersink_get_format(st->sink);
+            st->stream->codecpar->width               = av_buffersink_get_w(st->sink);
+            st->stream->codecpar->height              = av_buffersink_get_h(st->sink);
+            st->stream->codecpar->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(st->sink);
+            st->stream->codecpar->format              = av_buffersink_get_format(st->sink);
             break;
         case AVMEDIA_TYPE_AUDIO:
-            st->stream->codec->channel_layout = av_buffersink_get_channel_layout(st->sink);
-            st->stream->codec->channels       = av_buffersink_get_channels(st->sink);
-            st->stream->codec->sample_rate    = av_buffersink_get_sample_rate(st->sink);
-            st->stream->codec->sample_fmt     = av_buffersink_get_format(st->sink);
-            st->stream->codec->codec_id =
-                av_get_pcm_codec(st->stream->codec->sample_fmt, -1);
+            st->stream->codecpar->channel_layout = av_buffersink_get_channel_layout(st->sink);
+            st->stream->codecpar->channels       = av_buffersink_get_channels(st->sink);
+            st->stream->codecpar->sample_rate    = av_buffersink_get_sample_rate(st->sink);
+            st->stream->codecpar->format         = av_buffersink_get_format(st->sink);
+            st->stream->codecpar->codec_id       = av_get_pcm_codec(st->stream->codecpar->format, -1);
             break;
         default:
             av_assert0(!"reached");
@@ -245,7 +243,7 @@  int main(int argc, char **argv)
                                                          frame);
                 frame = NULL;
                 if (ret < 0) {
-                    av_log(st->stream->codec, AV_LOG_ERROR,
+                    av_log(st->mux, AV_LOG_ERROR,
                            "Error writing frame: %s\n", av_err2str(ret));
                     goto fail;
                 }
-- 
2.15.1