patch-picard_musicdns_avcodec_c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. $OpenBSD: patch-picard_musicdns_avcodec_c,v 1.1 2014/05/05 07:55:50 brad Exp $
  2. Deal with newer FFmpeg API.
  3. --- picard/musicdns/avcodec.c.orig Sun Oct 23 13:15:29 2011
  4. +++ picard/musicdns/avcodec.c Thu May 1 04:58:17 2014
  5. @@ -39,6 +39,10 @@
  6. #define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
  7. #endif
  8. +#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE
  9. +#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
  10. +#endif
  11. +
  12. static PyObject *
  13. init(PyObject *self, PyObject *args)
  14. {
  15. @@ -55,7 +59,7 @@ done(PyObject *self, PyObject *args)
  16. static PyObject *
  17. decode(PyObject *self, PyObject *args)
  18. {
  19. - AVFormatContext *format_context;
  20. + AVFormatContext *format_context = NULL;
  21. AVCodecContext *codec_context;
  22. AVCodec *codec;
  23. PyObject *filename;
  24. @@ -69,7 +73,11 @@ decode(PyObject *self, PyObject *args)
  25. return NULL;
  26. Py_UNBLOCK_THREADS
  27. +#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 2, 0)
  28. if (av_open_input_file(&format_context, PyString_AS_STRING(filename), NULL, 0, NULL) != 0) {
  29. +#else
  30. + if (avformat_open_input(&format_context, PyString_AS_STRING(filename), NULL, NULL) != 0) {
  31. +#endif
  32. Py_BLOCK_THREADS
  33. PyErr_SetString(PyExc_Exception, "Couldn't open the file.");
  34. return NULL;