]>
Commit | Line | Data |
---|---|---|
d62d471a JB |
1 | --- grass-6.4.3/lib/ogsf/gsd_img_mpeg.c.orig 2013-07-09 21:05:44.000000000 +0200 |
2 | +++ grass-6.4.3/lib/ogsf/gsd_img_mpeg.c 2014-06-10 21:53:30.055116809 +0200 | |
3 | @@ -31,7 +31,7 @@ | |
4 | #include <avutil.h> | |
7f1c1d86 | 5 | #else |
d62d471a JB |
6 | /* libavutil 51.22.1's avutil.h doesn't include libavutil/mathematics.h */ |
7 | -#include <mathematics.h> | |
8 | +#include <libavutil/mathematics.h> | |
9 | #endif | |
7f1c1d86 | 10 | |
d62d471a | 11 | /* 5 seconds stream duration */ |
4e718414 JB |
12 | @@ -38,7 +38,7 @@ |
13 | #define STREAM_DURATION 5.0 | |
14 | #define STREAM_FRAME_RATE 25 /* 25 images/s */ | |
15 | #define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE)) | |
16 | -#define STREAM_PIX_FMT PIX_FMT_YUV420P /* default pix_fmt */ | |
17 | +#define STREAM_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */ | |
18 | ||
19 | AVFrame *picture, *tmp_picture; | |
20 | uint8_t *video_outbuf; | |
21 | @@ -95,11 +95,11 @@ | |
22 | c->time_base.num = 1; | |
23 | c->gop_size = 12; /* emit one intra frame every twelve frames at most */ | |
24 | c->pix_fmt = STREAM_PIX_FMT; | |
25 | - if (c->codec_id == CODEC_ID_MPEG2VIDEO) { | |
26 | + if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) { | |
27 | /* just for testing, we also add B frames */ | |
28 | c->max_b_frames = 2; | |
29 | } | |
30 | - if (c->codec_id == CODEC_ID_MPEG1VIDEO) { | |
31 | + if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) { | |
32 | /* Needed to avoid using macroblocks in which some coeffs overflow. | |
33 | This does not happen with normal video, it just happens here as | |
34 | the motion of the chroma plane does not match the luma plane. */ | |
35 | @@ -138,7 +138,7 @@ | |
36 | uint8_t *picture_buf; | |
37 | int size; | |
38 | ||
39 | - picture = avcodec_alloc_frame(); | |
40 | + picture = av_frame_alloc(); | |
41 | ||
42 | if (!picture) | |
43 | return NULL; | |
44 | @@ -147,7 +147,7 @@ | |
45 | picture_buf = av_malloc(size); | |
46 | ||
47 | if (!picture_buf) { | |
48 | - av_free(picture); | |
49 | + av_frame_free(&picture); | |
50 | return NULL; | |
51 | } | |
52 | ||
53 | @@ -210,8 +210,8 @@ | |
54 | picture is needed too. It is then converted to the required | |
55 | output format */ | |
56 | tmp_picture = NULL; | |
57 | - if (c->pix_fmt != PIX_FMT_YUV420P) { | |
58 | - tmp_picture = alloc_picture(PIX_FMT_YUV420P, c->width, c->height); | |
59 | + if (c->pix_fmt != AV_PIX_FMT_YUV420P) { | |
60 | + tmp_picture = alloc_picture(AV_PIX_FMT_YUV420P, c->width, c->height); | |
61 | if (!tmp_picture) { | |
62 | G_warning(_("Unable to allocate temporary picture")); | |
63 | return; | |
64 | @@ -250,27 +250,20 @@ | |
65 | ret = av_write_frame(oc, &pkt); | |
66 | } | |
67 | else { | |
68 | + AVPacket pkt; | |
69 | + int got_packet; | |
70 | + av_init_packet(&pkt); | |
71 | + pkt.data = video_outbuf; | |
72 | + pkt.size = video_outbuf_size; | |
73 | /* encode the image */ | |
74 | - out_size = | |
75 | - avcodec_encode_video(c, video_outbuf, video_outbuf_size, picture); | |
76 | + ret = avcodec_encode_video2(c, &pkt, picture, &got_packet); | |
77 | /* if zero size, it means the image was buffered */ | |
78 | - if (out_size > 0) { | |
79 | - AVPacket pkt; | |
80 | - | |
81 | - av_init_packet(&pkt); | |
82 | + if ((ret >= 0) && got_packet) { | |
83 | ||
84 | pkt.pts = | |
85 | - av_rescale_q(c->coded_frame->pts, c->time_base, | |
86 | + av_rescale_q(pkt.pts, c->time_base, | |
87 | st->time_base); | |
88 | - if (c->coded_frame->key_frame) | |
89 | -#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 32, 0) | |
90 | - pkt.flags |= PKT_FLAG_KEY; | |
91 | -#else | |
92 | - pkt.flags |= AV_PKT_FLAG_KEY; | |
93 | -#endif | |
94 | pkt.stream_index = st->index; | |
95 | - pkt.data = video_outbuf; | |
96 | - pkt.size = out_size; | |
97 | ||
98 | /* write the compressed frame in the media file */ | |
99 | ret = av_write_frame(oc, &pkt); | |
100 | @@ -296,10 +289,10 @@ | |
101 | { | |
102 | avcodec_close(st->codec); | |
103 | av_free(picture->data[0]); | |
104 | - av_free(picture); | |
105 | + av_frame_free(&picture); | |
106 | if (tmp_picture) { | |
107 | av_free(tmp_picture->data[0]); | |
108 | - av_free(tmp_picture); | |
109 | + av_frame_free(&tmp_picture); | |
110 | } | |
111 | av_free(video_outbuf); | |
112 | } | |
113 | @@ -362,11 +362,11 @@ | |
114 | /* if you want to hardcode the codec (eg #ifdef USE_XVID) | |
115 | this may be the place to do it (?????) */ | |
116 | #ifdef USE_XVID | |
117 | - fmt->video_codec = CODEC_ID_XVID; | |
118 | + fmt->video_codec = AV_CODEC_ID_XVID; | |
119 | #endif | |
120 | ||
121 | video_st = NULL; | |
122 | - if (fmt->video_codec != CODEC_ID_NONE) { | |
123 | + if (fmt->video_codec != AV_CODEC_ID_NONE) { | |
124 | video_st = | |
125 | add_video_stream(oc, fmt->video_codec, (r - l + 1), (t - b + 1)); | |
126 | } |