Unified · Split
| @@ -60,12 +60,11 @@ static int audio_frame_count = 0; · 59 unmodified lines | ||
| 60 | 60 | * appropriate to your needs. Look for the use of api_mode in this example to |
| 61 | 61 | * see what are the differences of API usage between them */ |
| 62 | 62 | enum { |
| 63 | − API_MODE_OLD = 0, /* old method, deprecated */ | |
| 64 | 63 | API_MODE_NEW_API_REF_COUNT = 1, /* new method, using the frame reference counting */ |
| 65 | 64 | API_MODE_NEW_API_NO_REF_COUNT = 2, /* new method, without reference counting */ |
| 66 | 65 | }; |
| 67 | 66 | |
| 68 | −static int api_mode = API_MODE_OLD; | |
| 67 | +static int api_mode = API_MODE_NEW_API_NO_REF_COUNT; | |
| 69 | 68 | |
| 70 | 69 | static int decode_packet(int *got_frame, int cached) |
| 71 | 70 | { |
| @@ -243,8 +242,7 @@ int main (int argc, char **argv) · 171 unmodified lines | ||
| 243 | 242 | } |
| 244 | 243 | if (argc == 5) { |
| 245 | 244 | const char *mode = argv[1] + strlen("-refcount="); |
| 246 | − if (!strcmp(mode, "old")) api_mode = API_MODE_OLD; | |
| 247 | − else if (!strcmp(mode, "new_norefcount")) api_mode = API_MODE_NEW_API_NO_REF_COUNT; | |
| 245 | + if (!strcmp(mode, "new_norefcount")) api_mode = API_MODE_NEW_API_NO_REF_COUNT; | |
| 248 | 246 | else if (!strcmp(mode, "new_refcount")) api_mode = API_MODE_NEW_API_REF_COUNT; |
| 249 | 247 | else { |
| 250 | 248 | fprintf(stderr, "unknow mode '%s'\n", mode); |
| @@ -315,12 +313,7 @@ int main (int argc, char **argv) · 64 unmodified lines | ||
| 315 | 313 | goto end; |
| 316 | 314 | } |
| 317 | 315 | |
| 318 | − /* When using the new API, you need to use the libavutil/frame.h API, while | |
| 319 | − * the classic frame management is available in libavcodec */ | |
| 320 | − if (api_mode == API_MODE_OLD) | |
| 321 | − frame = avcodec_alloc_frame(); | |
| 322 | − else | |
| 323 | − frame = av_frame_alloc(); | |
| 316 | + frame = av_frame_alloc(); | |
| 324 | 317 | if (!frame) { |
| 325 | 318 | fprintf(stderr, "Could not allocate frame\n"); |
| 326 | 319 | ret = AVERROR(ENOMEM); |
| @@ -397,10 +390,7 @@ end: · 70 unmodified lines | ||
| 397 | 390 | fclose(video_dst_file); |
| 398 | 391 | if (audio_dst_file) |
| 399 | 392 | fclose(audio_dst_file); |
| 400 | − if (api_mode == API_MODE_OLD) | |
| 401 | − avcodec_free_frame(&frame); | |
| 402 | − else | |
| 403 | − av_frame_free(&frame); | |
| 393 | + av_frame_free(&frame); | |
| 404 | 394 | av_free(video_dst_data[0]); |
| 405 | 395 | |
| 406 | 396 | return ret < 0; |