diff mbox series

[FFmpeg-devel,1/3] doc/examples/demuxing_decoding: drop -refcount

Message ID 20200411150614.24578-1-anton@khirnov.net
State Accepted
Commit e4edf220e53c385aeadc9ff41ac99817899638c6
Headers show
Series [FFmpeg-devel,1/3] doc/examples/demuxing_decoding: drop -refcount
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Anton Khirnov April 11, 2020, 3:06 p.m. UTC
Non-refcounted frames are deprecated and there is no good reason to use
them.
---
 doc/examples/demuxing_decoding.c | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

Comments

James Almer April 11, 2020, 8:57 p.m. UTC | #1
On 4/11/2020 12:06 PM, Anton Khirnov wrote:
> Non-refcounted frames are deprecated and there is no good reason to use
> them.
> ---
>  doc/examples/demuxing_decoding.c | 28 ++++++----------------------
>  1 file changed, 6 insertions(+), 22 deletions(-)
> 
> diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c
> index 69a31a8935..9bde927321 100644
> --- a/doc/examples/demuxing_decoding.c
> +++ b/doc/examples/demuxing_decoding.c
> @@ -55,12 +55,6 @@ static AVPacket pkt;
>  static int video_frame_count = 0;
>  static int audio_frame_count = 0;
>  
> -/* Enable or disable frame reference counting. You are not supposed to support
> - * both paths in your application but pick the one most appropriate to your
> - * needs. Look for the use of refcount in this example to see what are the
> - * differences of API usage between them. */
> -static int refcount = 0;
> -
>  static int decode_packet(int *got_frame, int cached)
>  {
>      int ret = 0;
> @@ -138,9 +132,7 @@ static int decode_packet(int *got_frame, int cached)
>          }
>      }
>  
> -    /* If we use frame reference counting, we own the data and need
> -     * to de-reference it when we don't use it anymore */
> -    if (*got_frame && refcount)
> +    if (*got_frame)
>          av_frame_unref(frame);
>  
>      return decoded;
> @@ -186,8 +178,7 @@ static int open_codec_context(int *stream_idx,
>              return ret;
>          }
>  
> -        /* Init the decoders, with or without reference counting */
> -        av_dict_set(&opts, "refcounted_frames", refcount ? "1" : "0", 0);
> +        /* Init the decoders */
>          if ((ret = avcodec_open2(*dec_ctx, dec, &opts)) < 0) {
>              fprintf(stderr, "Failed to open %s codec\n",
>                      av_get_media_type_string(type));
> @@ -232,22 +223,15 @@ int main (int argc, char **argv)
>  {
>      int ret = 0, got_frame;
>  
> -    if (argc != 4 && argc != 5) {
> -        fprintf(stderr, "usage: %s [-refcount] input_file video_output_file audio_output_file\n"
> +    if (argc != 4) {
> +        fprintf(stderr, "usage: %s  input_file video_output_file audio_output_file\n"
>                  "API example program to show how to read frames from an input file.\n"
>                  "This program reads frames from a file, decodes them, and writes decoded\n"
>                  "video frames to a rawvideo file named video_output_file, and decoded\n"
> -                "audio frames to a rawaudio file named audio_output_file.\n\n"
> -                "If the -refcount option is specified, the program use the\n"
> -                "reference counting frame system which allows keeping a copy of\n"
> -                "the data for longer than one decode call.\n"
> -                "\n", argv[0]);
> +                "audio frames to a rawaudio file named audio_output_file.\n",
> +                argv[0]);
>          exit(1);
>      }
> -    if (argc == 5 && !strcmp(argv[1], "-refcount")) {
> -        refcount = 1;
> -        argv++;
> -    }
>      src_filename = argv[1];
>      video_dst_filename = argv[2];
>      audio_dst_filename = argv[3];

Should be ok.
diff mbox series

Patch

diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c
index 69a31a8935..9bde927321 100644
--- a/doc/examples/demuxing_decoding.c
+++ b/doc/examples/demuxing_decoding.c
@@ -55,12 +55,6 @@  static AVPacket pkt;
 static int video_frame_count = 0;
 static int audio_frame_count = 0;
 
-/* Enable or disable frame reference counting. You are not supposed to support
- * both paths in your application but pick the one most appropriate to your
- * needs. Look for the use of refcount in this example to see what are the
- * differences of API usage between them. */
-static int refcount = 0;
-
 static int decode_packet(int *got_frame, int cached)
 {
     int ret = 0;
@@ -138,9 +132,7 @@  static int decode_packet(int *got_frame, int cached)
         }
     }
 
-    /* If we use frame reference counting, we own the data and need
-     * to de-reference it when we don't use it anymore */
-    if (*got_frame && refcount)
+    if (*got_frame)
         av_frame_unref(frame);
 
     return decoded;
@@ -186,8 +178,7 @@  static int open_codec_context(int *stream_idx,
             return ret;
         }
 
-        /* Init the decoders, with or without reference counting */
-        av_dict_set(&opts, "refcounted_frames", refcount ? "1" : "0", 0);
+        /* Init the decoders */
         if ((ret = avcodec_open2(*dec_ctx, dec, &opts)) < 0) {
             fprintf(stderr, "Failed to open %s codec\n",
                     av_get_media_type_string(type));
@@ -232,22 +223,15 @@  int main (int argc, char **argv)
 {
     int ret = 0, got_frame;
 
-    if (argc != 4 && argc != 5) {
-        fprintf(stderr, "usage: %s [-refcount] input_file video_output_file audio_output_file\n"
+    if (argc != 4) {
+        fprintf(stderr, "usage: %s  input_file video_output_file audio_output_file\n"
                 "API example program to show how to read frames from an input file.\n"
                 "This program reads frames from a file, decodes them, and writes decoded\n"
                 "video frames to a rawvideo file named video_output_file, and decoded\n"
-                "audio frames to a rawaudio file named audio_output_file.\n\n"
-                "If the -refcount option is specified, the program use the\n"
-                "reference counting frame system which allows keeping a copy of\n"
-                "the data for longer than one decode call.\n"
-                "\n", argv[0]);
+                "audio frames to a rawaudio file named audio_output_file.\n",
+                argv[0]);
         exit(1);
     }
-    if (argc == 5 && !strcmp(argv[1], "-refcount")) {
-        refcount = 1;
-        argv++;
-    }
     src_filename = argv[1];
     video_dst_filename = argv[2];
     audio_dst_filename = argv[3];