Merge tag 'v0.1.4' into debian
[libam7xxx.git] / debian / patches / 0002-Revert-am7xxx-play-switch-to-avcodec_encode_video2.patch
1 From 70d093e78087c821c2c944df062f4a8ba10e2625 Mon Sep 17 00:00:00 2001
2 From: Antonio Ospite <ospite@studenti.unina.it>
3 Date: Mon, 18 Mar 2013 11:06:57 +0100
4 Subject: [PATCH] Revert "am7xxx-play: switch to avcodec_encode_video2()"
5 X-Face: z*RaLf`X<@C75u6Ig9}{oW$H;1_\2t5)({*|jhM<pyWR#k60!#=#>/Vb;]yA5<GWI5`6u&+
6  ;6b'@y|8w"wB;4/e!7wYYrcqdJFY,~%Gk_4]cq$Ei/7<j&N3ah(m`ku?pX.&+~:_/wC~dwn^)MizBG
7  !pE^+iDQQ1yC6^,)YDKkxDd!T>\I~93>J<_`<4)A{':UrE
8
9 This reverts commit b344c71f3e03f912d8b6ee7d96cdd67b31cdf8cc.
10
11 avcodec_encode_video2() has been introduced in lavc 54.01.0 but Debian Wheezy
12 ships with lavc 53, so for now we should revert this change for the Debian
13 packages.
14
15 When this patch will be dropped maybe the package should depend on
16 libavcodec54 as the old API may be disabled in the Debian packages.
17
18 ---
19  examples/am7xxx-play.c |   29 +++++++++--------------------
20  1 file changed, 9 insertions(+), 20 deletions(-)
21
22 diff --git a/examples/am7xxx-play.c b/examples/am7xxx-play.c
23 index 38812a4..0b1fa65 100644
24 --- a/examples/am7xxx-play.c
25 +++ b/examples/am7xxx-play.c
26 @@ -285,12 +285,9 @@ static int am7xxx_play(const char *input_format_string,
27         int out_buf_size;
28         uint8_t *out_buf;
29         int out_picture_size;
30 -       uint8_t *out_picture;
31         struct SwsContext *sw_scale_ctx;
32         AVPacket in_packet;
33 -       AVPacket out_packet;
34         int got_picture;
35 -       int got_packet;
36         int ret = 0;
37  
38         ret = video_input_init(&input_ctx, input_format_string, input_path, input_options);
39 @@ -393,26 +390,20 @@ static int am7xxx_play(const char *input_format_string,
40                                   picture_scaled->linesize);
41  
42                         if (output_ctx.raw_output) {
43 -                               out_picture = out_buf;
44                                 out_picture_size = out_buf_size;
45                         } else {
46                                 picture_scaled->quality = (output_ctx.codec_ctx)->global_quality;
47 -                               av_init_packet(&out_packet);
48 -                               out_packet.data = NULL;
49 -                               out_packet.size = 0;
50 -                               got_packet = 0;
51 -                               ret = avcodec_encode_video2(output_ctx.codec_ctx,
52 -                                                           &out_packet,
53 -                                                           picture_scaled,
54 -                                                           &got_packet);
55 -                               if (ret < 0 || !got_packet) {
56 +                               /* TODO: switch to avcodec_encode_video2() eventually */
57 +                               out_picture_size = avcodec_encode_video(output_ctx.codec_ctx,
58 +                                                                       out_buf,
59 +                                                                       out_buf_size,
60 +                                                                       picture_scaled);
61 +                               if (out_picture_size < 0) {
62                                         fprintf(stderr, "cannot encode video\n");
63 +                                       ret = out_picture_size;
64                                         run = 0;
65                                         goto end_while;
66                                 }
67 -
68 -                               out_picture = out_packet.data;
69 -                               out_picture_size = out_packet.size;
70                         }
71  
72  #ifdef DEBUG
73 @@ -423,7 +414,7 @@ static int am7xxx_play(const char *input_format_string,
74                         else
75                                 snprintf(filename, NAME_MAX, "out.raw");
76                         file = fopen(filename, "wb");
77 -                       fwrite(out_picture, 1, out_picture_size, file);
78 +                       fwrite(out_buf, 1, out_picture_size, file);
79                         fclose(file);
80  #endif
81  
82 @@ -431,7 +422,7 @@ static int am7xxx_play(const char *input_format_string,
83                                                 image_format,
84                                                 (output_ctx.codec_ctx)->width,
85                                                 (output_ctx.codec_ctx)->height,
86 -                                               out_picture,
87 +                                               out_buf,
88                                                 out_picture_size);
89                         if (ret < 0) {
90                                 perror("am7xxx_send_image");
91 @@ -440,8 +431,6 @@ static int am7xxx_play(const char *input_format_string,
92                         }
93                 }
94  end_while:
95 -               if (!output_ctx.raw_output)
96 -                       av_free_packet(&out_packet);
97                 av_free_packet(&in_packet);
98         }
99  
100 -- 
101 1.7.10.4
102