OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 // the raw compressed data. | 26 // the raw compressed data. |
27 // | 27 // |
28 // Standard Includes | 28 // Standard Includes |
29 // ----------------- | 29 // ----------------- |
30 // For decoders, you only have to include `vpx_decoder.h` and then any | 30 // For decoders, you only have to include `vpx_decoder.h` and then any |
31 // header files for the specific codecs you use. In this case, we're using | 31 // header files for the specific codecs you use. In this case, we're using |
32 // vp8. | 32 // vp8. |
33 // | 33 // |
34 // Initializing The Codec | 34 // Initializing The Codec |
35 // ---------------------- | 35 // ---------------------- |
36 // The decoder is initialized by the following code. This is an example for | 36 // The libvpx decoder is initialized by the call to vpx_codec_dec_init(). |
37 // the VP8 decoder, but the code is analogous for all algorithms. Replace | 37 // Determining the codec interface to use is handled by VpxVideoReader and the |
38 // `vpx_codec_vp8_dx()` with a pointer to the interface exposed by the | 38 // functions prefixed with vpx_video_reader_. Discussion of those functions is |
39 // algorithm you want to use. The `cfg` argument is left as NULL in this | 39 // beyond the scope of this example, but the main gist is to open the input file |
40 // example, because we want the algorithm to determine the stream | 40 // and parse just enough of it to determine if it's a VPx file and which VPx |
41 // configuration (width/height) and allocate memory automatically. This | 41 // codec is contained within the file. |
42 // parameter is generally only used if you need to preallocate memory, | 42 // Note the NULL pointer passed to vpx_codec_dec_init(). We do that in this |
43 // particularly in External Memory Allocation mode. | 43 // example because we want the algorithm to determine the stream configuration |
| 44 // (width/height) and allocate memory automatically. |
44 // | 45 // |
45 // Decoding A Frame | 46 // Decoding A Frame |
46 // ---------------- | 47 // ---------------- |
47 // Once the frame has been read into memory, it is decoded using the | 48 // Once the frame has been read into memory, it is decoded using the |
48 // `vpx_codec_decode` function. The call takes a pointer to the data | 49 // `vpx_codec_decode` function. The call takes a pointer to the data |
49 // (`frame`) and the length of the data (`frame_sz`). No application data | 50 // (`frame`) and the length of the data (`frame_size`). No application data |
50 // is associated with the frame in this example, so the `user_priv` | 51 // is associated with the frame in this example, so the `user_priv` |
51 // parameter is NULL. The `deadline` parameter is left at zero for this | 52 // parameter is NULL. The `deadline` parameter is left at zero for this |
52 // example. This parameter is generally only used when doing adaptive | 53 // example. This parameter is generally only used when doing adaptive post |
53 // postprocessing. | 54 // processing. |
54 // | 55 // |
55 // Codecs may produce a variable number of output frames for every call to | 56 // Codecs may produce a variable number of output frames for every call to |
56 // `vpx_codec_decode`. These frames are retrieved by the | 57 // `vpx_codec_decode`. These frames are retrieved by the |
57 // `vpx_codec_get_frame` iterator function. The iterator variable `iter` is | 58 // `vpx_codec_get_frame` iterator function. The iterator variable `iter` is |
58 // initialized to NULL each time `vpx_codec_decode` is called. | 59 // initialized to NULL each time `vpx_codec_decode` is called. |
59 // `vpx_codec_get_frame` is called in a loop, returning a pointer to a | 60 // `vpx_codec_get_frame` is called in a loop, returning a pointer to a |
60 // decoded image or NULL to indicate the end of list. | 61 // decoded image or NULL to indicate the end of list. |
61 // | 62 // |
62 // Processing The Decoded Data | 63 // Processing The Decoded Data |
63 // --------------------------- | 64 // --------------------------- |
64 // In this example, we simply write the encoded data to disk. It is | 65 // In this example, we simply write the encoded data to disk. It is |
65 // important to honor the image's `stride` values. | 66 // important to honor the image's `stride` values. |
66 // | 67 // |
67 // Cleanup | 68 // Cleanup |
68 // ------- | 69 // ------- |
69 // The `vpx_codec_destroy` call frees any memory allocated by the codec. | 70 // The `vpx_codec_destroy` call frees any memory allocated by the codec. |
70 // | 71 // |
71 // Error Handling | 72 // Error Handling |
72 // -------------- | 73 // -------------- |
73 // This example does not special case any error return codes. If there was | 74 // This example does not special case any error return codes. If there was |
74 // an error, a descriptive message is printed and the program exits. With | 75 // an error, a descriptive message is printed and the program exits. With |
75 // few exeptions, vpx_codec functions return an enumerated error status, | 76 // few exceptions, vpx_codec functions return an enumerated error status, |
76 // with the value `0` indicating success. | 77 // with the value `0` indicating success. |
77 | 78 |
78 #include <stdio.h> | 79 #include <stdio.h> |
79 #include <stdlib.h> | 80 #include <stdlib.h> |
80 #include <string.h> | 81 #include <string.h> |
81 | 82 |
82 #include "vpx/vp8dx.h" | |
83 #include "vpx/vpx_decoder.h" | 83 #include "vpx/vpx_decoder.h" |
84 | 84 |
85 #include "./tools_common.h" | 85 #include "./tools_common.h" |
86 #include "./video_reader.h" | 86 #include "./video_reader.h" |
87 #include "./vpx_config.h" | 87 #include "./vpx_config.h" |
88 | 88 |
89 static const char *exec_name; | 89 static const char *exec_name; |
90 | 90 |
91 void usage_exit() { | 91 void usage_exit() { |
92 fprintf(stderr, "Usage: %s <infile> <outfile>\n", exec_name); | 92 fprintf(stderr, "Usage: %s <infile> <outfile>\n", exec_name); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 printf("Play: ffplay -f rawvideo -pix_fmt yuv420p -s %dx%d %s\n", | 146 printf("Play: ffplay -f rawvideo -pix_fmt yuv420p -s %dx%d %s\n", |
147 info->frame_width, info->frame_height, argv[2]); | 147 info->frame_width, info->frame_height, argv[2]); |
148 | 148 |
149 vpx_video_reader_close(reader); | 149 vpx_video_reader_close(reader); |
150 | 150 |
151 fclose(outfile); | 151 fclose(outfile); |
152 | 152 |
153 return EXIT_SUCCESS; | 153 return EXIT_SUCCESS; |
154 } | 154 } |
OLD | NEW |