1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
Index: libaf/af_lavcac3enc.c
===================================================================
--- libaf/af_lavcac3enc.c (revision 38679)
+++ libaf/af_lavcac3enc.c (working copy)
@@ -100,9 +100,14 @@
s->lavc_actx->sample_rate != af->data->rate ||
s->lavc_actx->bit_rate != bit_rate) {
- if (s->lavc_actx->codec)
- avcodec_close(s->lavc_actx);
+ avcodec_free_context(&s->lavc_actx);
+ s->lavc_actx = avcodec_alloc_context3(NULL);
+ if (!s->lavc_actx) {
+ mp_msg(MSGT_AFILTER, MSGL_ERR, MSGTR_CouldntAllocateLavcContext);
+ return AF_ERROR;
+ }
+
// Put sample parameters
s->lavc_actx->ch_layout.nb_channels = af->data->nch;
s->lavc_actx->sample_rate = af->data->rate;
@@ -157,9 +162,7 @@
af_ac3enc_t *s = af->setup;
af->setup = NULL;
if(s->lavc_actx) {
- if (s->lavc_actx->codec)
- avcodec_close(s->lavc_actx);
- free(s->lavc_actx);
+ avcodec_free_context(&s->lavc_actx);
}
free(s->pending_data);
free(s);
@@ -280,12 +283,6 @@
return AF_ERROR;
}
- s->lavc_actx = avcodec_alloc_context3(NULL);
- if (!s->lavc_actx) {
- mp_msg(MSGT_AFILTER, MSGL_ERR, MSGTR_CouldntAllocateLavcContext);
- return AF_ERROR;
- }
-
return AF_OK;
}
Index: libmpcodecs/ad_ffmpeg.c
===================================================================
--- libmpcodecs/ad_ffmpeg.c (revision 38679)
+++ libmpcodecs/ad_ffmpeg.c (working copy)
@@ -196,11 +196,9 @@
{
AVCodecContext *lavc_context = sh->context;
- if (avcodec_close(lavc_context) < 0)
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec);
av_freep(&lavc_context->opaque);
av_freep(&lavc_context->extradata);
- av_freep(&lavc_context);
+ avcodec_free_context(&lavc_context);
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
Index: libmpcodecs/vd_ffmpeg.c
===================================================================
--- libmpcodecs/vd_ffmpeg.c (revision 38679)
+++ libmpcodecs/vd_ffmpeg.c (working copy)
@@ -511,9 +511,6 @@
}
if (avctx) {
- if (avctx->codec && avcodec_close(avctx) < 0)
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec);
-
av_freep(&avctx->extradata);
av_freep(&avctx->hwaccel_context);
}
@@ -1060,8 +1057,8 @@
// mpi->qscale = av_frame_get_qp_table(pic, &mpi->qstride, &mpi->qscale_type);
mpi->pict_type=pic->pict_type;
mpi->fields = MP_IMGFIELD_ORDERED;
- if(pic->interlaced_frame) mpi->fields |= MP_IMGFIELD_INTERLACED;
- if(pic->top_field_first ) mpi->fields |= MP_IMGFIELD_TOP_FIRST;
+ if(pic->flags & AV_FRAME_FLAG_INTERLACED) mpi->fields |= MP_IMGFIELD_INTERLACED;
+ if(pic->flags &AV_FRAME_FLAG_TOP_FIELD_FIRST ) mpi->fields |= MP_IMGFIELD_TOP_FIRST;
if(pic->repeat_pict == 1) mpi->fields |= MP_IMGFIELD_REPEAT_FIRST;
return mpi;
Index: libmpcodecs/ve_lavc.c
===================================================================
--- libmpcodecs/ve_lavc.c (revision 38679)
+++ libmpcodecs/ve_lavc.c (working copy)
@@ -152,7 +152,7 @@
static int lavc_param_mv0_threshold = 256;
static int lavc_param_refs = 1;
static int lavc_param_b_sensitivity = 40;
-static int lavc_param_level = FF_LEVEL_UNKNOWN;
+static int lavc_param_level = AV_LEVEL_UNKNOWN;
char *lavc_param_acodec = "mp2";
int lavc_param_atag = 0;
@@ -722,12 +722,12 @@
if(lavc_param_interlaced_dct){
if((mpi->fields & MP_IMGFIELD_ORDERED) && (mpi->fields & MP_IMGFIELD_INTERLACED))
- pic->top_field_first= !!(mpi->fields & MP_IMGFIELD_TOP_FIRST);
+ pic->flags |= (mpi->fields & MP_IMGFIELD_TOP_FIRST) ? AV_FRAME_FLAG_TOP_FIELD_FIRST : 0;
else
- pic->top_field_first= 1;
+ pic->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
if(lavc_param_top!=-1)
- pic->top_field_first= lavc_param_top;
+ pic->flags= (pic->flags & ~AV_FRAME_FLAG_TOP_FIELD_FIRST) | lavc_param_top ? AV_FRAME_FLAG_TOP_FIELD_FIRST : 0;
}
return encode_frame(vf, pic, pts) >= 0;
@@ -852,9 +852,6 @@
av_freep(&lavc_venc_context->intra_matrix);
av_freep(&lavc_venc_context->inter_matrix);
- if (lavc_venc_context->codec)
- avcodec_close(lavc_venc_context);
-
if(stats_file) fclose(stats_file);
/* free rc_override */
Index: libmpcodecs/vf_mcdeint.c
===================================================================
--- libmpcodecs/vf_mcdeint.c (revision 38679)
+++ libmpcodecs/vf_mcdeint.c (working copy)
@@ -313,8 +313,7 @@
}
#endif
if (vf->priv->avctx_enc) {
- avcodec_close(vf->priv->avctx_enc);
- av_freep(&vf->priv->avctx_enc);
+ avcodec_free_context(&vf->priv->avctx_enc);
}
free(vf->priv->outbuf);
Index: libmpcodecs/vf_screenshot.c
===================================================================
--- libmpcodecs/vf_screenshot.c (revision 38679)
+++ libmpcodecs/vf_screenshot.c (working copy)
@@ -279,8 +279,7 @@
static void uninit(vf_instance_t *vf)
{
- avcodec_close(vf->priv->avctx);
- av_freep(&vf->priv->avctx);
+ avcodec_free_context(&vf->priv->avctx);
if(vf->priv->ctx) sws_freeContext(vf->priv->ctx);
av_freep(&vf->priv->pic->data[0]);
av_frame_free(&vf->priv->pic);
Index: libmpdemux/demux_lavf.c
===================================================================
--- libmpdemux/demux_lavf.c (revision 38679)
+++ libmpdemux/demux_lavf.c (working copy)
@@ -367,7 +367,10 @@
st->discard= AVDISCARD_ALL;
if (priv->audio_streams == 0) {
size_t rg_size;
- AVReplayGain *rg = (AVReplayGain*)av_stream_get_side_data(st, AV_PKT_DATA_REPLAYGAIN, &rg_size);
+ const AVPacketSideData *sd = av_packet_side_data_get(st->codecpar->coded_side_data,
+ st->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_REPLAYGAIN);
+ AVReplayGain *rg = sd ? (AVReplayGain*)sd->data : NULL;
if (rg && rg_size >= sizeof(*rg)) {
priv->r_gain = rg->track_gain / 10000;
}
@@ -378,7 +381,10 @@
}
case AVMEDIA_TYPE_VIDEO:{
AVDictionaryEntry *rot = av_dict_get(st->metadata, "rotate", NULL, 0);
- const int32_t *disp_matrix = (const int32_t *)av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, NULL);
+ const AVPacketSideData *sd = av_packet_side_data_get(st->codecpar->coded_side_data,
+ st->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_DISPLAYMATRIX);
+ const int32_t *disp_matrix = sd ? (const int32_t *)sd->data : NULL;
sh_video_t* sh_video;
BITMAPINFOHEADER *bih;
sh_video=new_sh_video_vid(demuxer, i, priv->video_streams);
Index: libvo/vo_png.c
===================================================================
--- libvo/vo_png.c (revision 38679)
+++ libvo/vo_png.c (working copy)
@@ -126,8 +126,7 @@
if (avctx && png_format != format) {
- avcodec_close(avctx);
- av_freep(&avctx);
+ avcodec_free_context(&avctx);
}
if (!avctx) {
@@ -214,8 +213,7 @@
}
static void uninit(void){
- avcodec_close(avctx);
- av_freep(&avctx);
+ avcodec_free_context(&avctx);
av_freep(&outbuffer);
outbuffer_size = 0;
free(png_outdir);
Index: sub/av_sub.c
===================================================================
--- sub/av_sub.c (revision 38679)
+++ sub/av_sub.c (working copy)
@@ -30,8 +30,7 @@
AVCodecContext *ctx = sh->context;
ctx->extradata = NULL;
ctx->extradata_size = 0;
- avcodec_close(sh->context);
- av_freep(&sh->context);
+ avcodec_free_context((AVCodecContext **)&sh->context);
}
}
|