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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
|
Description: Replace deprecated FFmpeg API
Author: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Last-Update: <2015-11-02>
--- gmerlin-encoders-1.2.0.orig/plugins/ffmpeg/codecs.c
+++ gmerlin-encoders-1.2.0/plugins/ffmpeg/codecs.c
@@ -119,7 +119,6 @@
}, \
PARAM_GOP_SIZE, \
PARAM_SCENE_CHANGE_THRESHOLD, \
- PARAM_SCENECHANGE_FACTOR, \
PARAM_FLAG_CLOSED_GOP \
#define ENCODE_PARAM_VIDEO_FRAMETYPES_IPB \
@@ -414,63 +413,63 @@ static const ffmpeg_codec_info_t video_c
.long_name = TRS("Motion JPEG"),
.id = AV_CODEC_ID_MJPEG,
.parameters = parameters_mjpeg,
- .pixelformats = (enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_NB },
+ .pixelformats = (enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NB },
},
{
.name = "mpeg4",
.long_name = TRS("MPEG-4"),
.id = AV_CODEC_ID_MPEG4,
.parameters = parameters_mpeg4,
- .pixelformats = (enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NB },
+ .pixelformats = (enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NB },
},
{
.name = "msmpeg4v3",
.long_name = TRS("Divx 3 compatible"),
.id = AV_CODEC_ID_MSMPEG4V3,
.parameters = parameters_msmpeg4v3,
- .pixelformats = (enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NB },
+ .pixelformats = (enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NB },
},
{
.name = "mpeg1video",
.long_name = TRS("MPEG-1 Video"),
.id = AV_CODEC_ID_MPEG1VIDEO,
.parameters = parameters_mpeg1,
- .pixelformats = (enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NB },
+ .pixelformats = (enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NB },
},
{
.name = "mpeg2video",
.long_name = TRS("MPEG-2 Video"),
.id = AV_CODEC_ID_MPEG2VIDEO,
.parameters = parameters_mpeg1,
- .pixelformats = (enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NB },
+ .pixelformats = (enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NB },
},
{
.name = "flv1",
.long_name = TRS("Flash 1"),
.id = AV_CODEC_ID_FLV1,
.parameters = parameters_msmpeg4v3,
- .pixelformats = (enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NB },
+ .pixelformats = (enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NB },
},
{
.name = "wmv1",
.long_name = TRS("WMV 1"),
.id = AV_CODEC_ID_WMV1,
.parameters = parameters_msmpeg4v3,
- .pixelformats = (enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NB },
+ .pixelformats = (enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NB },
},
{
.name = "rv10",
.long_name = TRS("Real Video 1"),
.id = AV_CODEC_ID_RV10,
.parameters = parameters_msmpeg4v3,
- .pixelformats = (enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NB },
+ .pixelformats = (enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NB },
},
{
.name = "libx264",
.long_name = TRS("H.264"),
.id = AV_CODEC_ID_H264,
.parameters = parameters_libx264,
- .pixelformats = (enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NB },
+ .pixelformats = (enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NB },
},
#if 0
{
@@ -972,7 +971,6 @@ bg_ffmpeg_set_codec_parameter(AVCodecCon
PARAM_INT("ff_me_penalty_compensation",me_penalty_compensation);
PARAM_INT("ff_bidir_refine",bidir_refine);
PARAM_INT("ff_brd_scale",brd_scale);
- PARAM_INT("ff_scenechange_factor",scenechange_factor);
PARAM_FLAG("ff_flag_qscale",CODEC_FLAG_QSCALE);
PARAM_FLAG("ff_flag_4mv",CODEC_FLAG_4MV);
PARAM_FLAG("ff_flag_qpel",CODEC_FLAG_QPEL);
@@ -980,7 +978,6 @@ bg_ffmpeg_set_codec_parameter(AVCodecCon
PARAM_FLAG("ff_flag_mv0",CODEC_FLAG_MV0);
// PARAM_FLAG("ff_flag_part",CODEC_FLAG_PART);
PARAM_FLAG("ff_flag_gray",CODEC_FLAG_GRAY);
- PARAM_FLAG("ff_flag_emu_edge",CODEC_FLAG_EMU_EDGE);
PARAM_FLAG("ff_flag_normalize_aqp",CODEC_FLAG_NORMALIZE_AQP);
// PARAM_FLAG("ff_flag_alt_scan",CODEC_FLAG_ALT_SCAN);
#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
@@ -1007,7 +1004,7 @@ bg_ffmpeg_set_codec_parameter(AVCodecCon
}
-enum PixelFormat * bg_ffmpeg_get_pixelformats(enum AVCodecID id)
+enum AVPixelFormat * bg_ffmpeg_get_pixelformats(enum AVCodecID id)
{
int i = 0;
while(video_codecs[i].name)
--- gmerlin-encoders-1.2.0.orig/plugins/ffmpeg/ffmpeg_common.c
+++ gmerlin-encoders-1.2.0/plugins/ffmpeg/ffmpeg_common.c
@@ -777,7 +777,7 @@ static int open_video_encoder(ffmpeg_pri
st->buffer_alloc = st->format.image_width * st->format.image_width * 4;
st->buffer = malloc(st->buffer_alloc);
- st->frame = avcodec_alloc_frame();
+ st->frame = av_frame_alloc();
st->initialized = 1;
return 1;
@@ -888,26 +888,27 @@ static int flush_audio(ffmpeg_priv_t * p
ffmpeg_audio_stream_t * st)
{
AVPacket pkt;
- AVFrame f;
+ AVFrame *f = av_frame_alloc();
int got_packet;
+ int ret = 0;
av_init_packet(&pkt);
pkt.data = st->buffer;
pkt.size = st->buffer_alloc;
- avcodec_get_frame_defaults(&f);
- f.nb_samples = st->frame->valid_samples;
+ av_frame_unref(f);
+ f->nb_samples = st->frame->valid_samples;
- f.pts = st->samples_written;
+ f->pts = st->samples_written;
- avcodec_fill_audio_frame(&f, st->format.num_channels, st->stream->codec->sample_fmt,
+ avcodec_fill_audio_frame(f, st->format.num_channels, st->stream->codec->sample_fmt,
st->frame->samples.u_8,
st->stream->codec->frame_size * st->format.num_channels * 2, 1);
if(avcodec_encode_audio2(st->stream->codec, &pkt,
- &f, &got_packet) < 0)
- return 0;
+ f, &got_packet) < 0)
+ goto end;
if(got_packet && pkt.size)
{
@@ -924,7 +925,7 @@ static int flush_audio(ffmpeg_priv_t * p
// if(av_write_frame(priv->ctx, &pkt) != 0)
{
priv->got_error = 1;
- return 0;
+ goto end;
}
}
@@ -933,7 +934,10 @@ static int flush_audio(ffmpeg_priv_t * p
st->frame->valid_samples = 0;
st->samples_written += st->format.samples_per_frame;
- return pkt.size;
+ ret = pkt.size;
+ end:
+ av_frame_free(&f);
+ return ret;
}
#else
@@ -1238,7 +1242,7 @@ static void close_video_encoder(ffmpeg_p
// st->stream->codec = NULL;
if(st->frame)
- free(st->frame);
+ av_frame_free(&st->frame);
if(st->buffer)
free(st->buffer);
@@ -1321,50 +1325,50 @@ const bg_encoder_framerate_t bg_ffmpeg_m
static const struct
{
- enum PixelFormat ffmpeg_csp;
+ enum AVPixelFormat ffmpeg_csp;
gavl_pixelformat_t gavl_csp;
}
pixelformats[] =
{
- { PIX_FMT_YUV420P, GAVL_YUV_420_P }, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
+ { AV_PIX_FMT_YUV420P, GAVL_YUV_420_P }, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
#if LIBAVUTIL_VERSION_INT < (50<<16)
- { PIX_FMT_YUV422, GAVL_YUY2 },
+ { AV_PIX_FMT_YUV422, GAVL_YUY2 },
#else
- { PIX_FMT_YUYV422, GAVL_YUY2 },
+ { AV_PIX_FMT_YUYV422, GAVL_YUY2 },
#endif
- { PIX_FMT_YUV422P, GAVL_YUV_422_P }, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
- { PIX_FMT_YUV444P, GAVL_YUV_444_P }, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
- { PIX_FMT_YUV411P, GAVL_YUV_411_P }, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
- { PIX_FMT_YUVJ420P, GAVL_YUVJ_420_P }, ///< Planar YUV 4:2:0 full scale (jpeg)
- { PIX_FMT_YUVJ422P, GAVL_YUVJ_422_P }, ///< Planar YUV 4:2:2 full scale (jpeg)
- { PIX_FMT_YUVJ444P, GAVL_YUVJ_444_P }, ///< Planar YUV 4:4:4 full scale (jpeg)
+ { AV_PIX_FMT_YUV422P, GAVL_YUV_422_P }, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
+ { AV_PIX_FMT_YUV444P, GAVL_YUV_444_P }, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
+ { AV_PIX_FMT_YUV411P, GAVL_YUV_411_P }, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
+ { AV_PIX_FMT_YUVJ420P, GAVL_YUVJ_420_P }, ///< Planar YUV 4:2:0 full scale (jpeg)
+ { AV_PIX_FMT_YUVJ422P, GAVL_YUVJ_422_P }, ///< Planar YUV 4:2:2 full scale (jpeg)
+ { AV_PIX_FMT_YUVJ444P, GAVL_YUVJ_444_P }, ///< Planar YUV 4:4:4 full scale (jpeg)
#if 0 // Not needed in the forseeable future
- { PIX_FMT_RGB24, GAVL_RGB_24 }, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
- { PIX_FMT_BGR24, GAVL_BGR_24 }, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
+ { AV_PIX_FMT_RGB24, GAVL_RGB_24 }, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
+ { AV_PIX_FMT_BGR24, GAVL_BGR_24 }, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
#if LIBAVUTIL_VERSION_INT < (50<<16)
- { PIX_FMT_RGBA32, GAVL_RGBA_32 }, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
+ { AV_PIX_FMT_RGBA32, GAVL_RGBA_32 }, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
#else
- { PIX_FMT_RGB32, GAVL_RGBA_32 }, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
+ { AV_PIX_FMT_RGB32, GAVL_RGBA_32 }, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
#endif
- { PIX_FMT_YUV410P, GAVL_YUV_410_P }, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
- { PIX_FMT_RGB565, GAVL_RGB_16 }, ///< always stored in cpu endianness
- { PIX_FMT_RGB555, GAVL_RGB_15 }, ///< always stored in cpu endianness, most significant bit to 1
- { PIX_FMT_GRAY8, GAVL_PIXELFORMAT_NONE },
- { PIX_FMT_MONOWHITE, GAVL_PIXELFORMAT_NONE }, ///< 0 is white
- { PIX_FMT_MONOBLACK, GAVL_PIXELFORMAT_NONE }, ///< 0 is black
- // { PIX_FMT_PAL8, GAVL_RGB_24 }, ///< 8 bit with RGBA palette
- { PIX_FMT_XVMC_MPEG2_MC, GAVL_PIXELFORMAT_NONE }, ///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
- { PIX_FMT_XVMC_MPEG2_IDCT, GAVL_PIXELFORMAT_NONE },
+ { AV_PIX_FMT_YUV410P, GAVL_YUV_410_P }, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
+ { AV_PIX_FMT_RGB565, GAVL_RGB_16 }, ///< always stored in cpu endianness
+ { AV_PIX_FMT_RGB555, GAVL_RGB_15 }, ///< always stored in cpu endianness, most significant bit to 1
+ { AV_PIX_FMT_GRAY8, GAVL_PIXELFORMAT_NONE },
+ { AV_PIX_FMT_MONOWHITE, GAVL_PIXELFORMAT_NONE }, ///< 0 is white
+ { AV_PIX_FMT_MONOBLACK, GAVL_PIXELFORMAT_NONE }, ///< 0 is black
+ // { AV_PIX_FMT_PAL8, GAVL_RGB_24 }, ///< 8 bit with RGBA palette
+ { AV_PIX_FMT_XVMC_MPEG2_MC, GAVL_PIXELFORMAT_NONE }, ///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
+ { AV_PIX_FMT_XVMC_MPEG2_IDCT, GAVL_PIXELFORMAT_NONE },
#if LIBAVCODEC_BUILD >= ((51<<16)+(45<<8)+0)
- { PIX_FMT_YUVA420P, GAVL_YUVA_32 },
+ { AV_PIX_FMT_YUVA420P, GAVL_YUVA_32 },
#endif
#endif // Not needed
- { PIX_FMT_NB, GAVL_PIXELFORMAT_NONE }
+ { AV_PIX_FMT_NB, GAVL_PIXELFORMAT_NONE }
};
-gavl_pixelformat_t bg_pixelformat_ffmpeg_2_gavl(enum PixelFormat p)
+gavl_pixelformat_t bg_pixelformat_ffmpeg_2_gavl(enum AVPixelFormat p)
{
int i;
for(i = 0; i < sizeof(pixelformats)/sizeof(pixelformats[0]); i++)
@@ -1375,7 +1379,7 @@ gavl_pixelformat_t bg_pixelformat_ffmpeg
return GAVL_PIXELFORMAT_NONE;
}
-enum PixelFormat bg_pixelformat_gavl_2_ffmpeg(gavl_pixelformat_t p)
+enum AVPixelFormat bg_pixelformat_gavl_2_ffmpeg(gavl_pixelformat_t p)
{
int i;
for(i = 0; i < sizeof(pixelformats)/sizeof(pixelformats[0]); i++)
@@ -1383,7 +1387,7 @@ enum PixelFormat bg_pixelformat_gavl_2_f
if(pixelformats[i].gavl_csp == p)
return pixelformats[i].ffmpeg_csp;
}
- return PIX_FMT_NONE;
+ return AV_PIX_FMT_NONE;
}
--- gmerlin-encoders-1.2.0.orig/plugins/ffmpeg/ffmpeg_common.h
+++ gmerlin-encoders-1.2.0/plugins/ffmpeg/ffmpeg_common.h
@@ -61,7 +61,7 @@ typedef struct
const bg_parameter_info_t * parameters;
/* Terminated with PIX_FMT_NB */
- enum PixelFormat * pixelformats;
+ enum AVPixelFormat * pixelformats;
} ffmpeg_codec_info_t;
@@ -237,7 +237,7 @@ void bg_ffmpeg_set_audio_parameter(void
void bg_ffmpeg_set_video_parameter(void * data, int stream, const char * name,
const bg_parameter_value_t * v);
-enum PixelFormat * bg_ffmpeg_get_pixelformats(enum AVCodecID id);
+enum AVPixelFormat * bg_ffmpeg_get_pixelformats(enum AVCodecID id);
int bg_ffmpeg_set_video_pass(void * data, int stream, int pass,
@@ -264,8 +264,8 @@ int bg_ffmpeg_write_subtitle_text(void *
int bg_ffmpeg_close(void * data, int do_delete);
-gavl_pixelformat_t bg_pixelformat_ffmpeg_2_gavl(enum PixelFormat p);
-enum PixelFormat bg_pixelformat_gavl_2_ffmpeg(gavl_pixelformat_t p);
+gavl_pixelformat_t bg_pixelformat_ffmpeg_2_gavl(enum AVPixelFormat p);
+enum AVPixelFormat bg_pixelformat_gavl_2_ffmpeg(gavl_pixelformat_t p);
gavl_sample_format_t bg_sample_format_ffmpeg_2_gavl(enum SampleFormat p);
--- gmerlin-encoders-1.2.0.orig/plugins/ffmpeg/params.h
+++ gmerlin-encoders-1.2.0/plugins/ffmpeg/params.h
@@ -146,7 +146,7 @@ TRS("X1"), TRS("Epzs"), TRS("Full"), (ch
.type = BG_PARAMETER_SLIDER_INT, \
.val_default = { .val_i = 0 }, \
.val_min = { .val_i = 0 }, \
- .val_max = { .val_i = FF_MAX_B_FRAMES }, \
+ .val_max = { .val_i = INT_MAX }, \
.help_string = TRS("Maximum number of B-frames between non B-frames") \
}
@@ -763,16 +763,6 @@ RC buffer size") \
}
-/** Frame types */
-#define PARAM_SCENECHANGE_FACTOR \
- { \
- .name = "ff_scenechange_factor", \
- .long_name = TRS("Scenechange factor"), \
- .type = BG_PARAMETER_INT, \
- .val_default = { .val_i = 0 }, \
- .help_string = TRS("Multiplied by qscale for each frame and added to scene_change_score") \
- }
-
/** Quantizer */
#define PARAM_QSCALE \
{ \
|