cavsdec: Make sure a sequence header has been decoded before decoding pictures
[ffmpeg.git] / libavdevice / libcdio.c
index be1c516..06ddb4a 100644 (file)
  * libcdio CD grabbing
  */
 
+#include "config.h"
+
+#if HAVE_CDIO_PARANOIA_H
 #include <cdio/cdda.h>
 #include <cdio/paranoia.h>
+#elif HAVE_CDIO_PARANOIA_PARANOIA_H
+#include <cdio/paranoia/cdda.h>
+#include <cdio/paranoia/paranoia.h>
+#endif
 
 #include "libavutil/log.h"
 #include "libavutil/mem.h"
 #include "libavformat/avformat.h"
 #include "libavformat/internal.h"
 
-/* cdio returns some malloced strings that need to be free()d */
-#undef free
-
 typedef struct CDIOContext {
+    AVClass             *class;
     cdrom_drive_t       *drive;
     cdrom_paranoia_t *paranoia;
     int32_t last_sector;
@@ -46,14 +51,14 @@ typedef struct CDIOContext {
     int paranoia_mode;
 } CDIOContext;
 
-static av_cold int read_header(AVFormatContext *ctx, AVFormatParameters *ap)
+static av_cold int read_header(AVFormatContext *ctx)
 {
     CDIOContext *s = ctx->priv_data;
     AVStream *st;
     int ret, i;
     char *err = NULL;
 
-    if (!(st = av_new_stream(ctx, 0)))
+    if (!(st = avformat_new_stream(ctx, NULL)))
         return AVERROR(ENOMEM);
     s->drive = cdio_cddap_identify(ctx->filename, CDDA_MESSAGE_LOGIT, &err);
     if (!s->drive) {
@@ -82,9 +87,9 @@ static av_cold int read_header(AVFormatContext *ctx, AVFormatParameters *ap)
 
     st->codec->codec_type      = AVMEDIA_TYPE_AUDIO;
     if (s->drive->bigendianp)
-        st->codec->codec_id    = CODEC_ID_PCM_S16BE;
+        st->codec->codec_id    = AV_CODEC_ID_PCM_S16BE;
     else
-        st->codec->codec_id    = CODEC_ID_PCM_S16LE;
+        st->codec->codec_id    = AV_CODEC_ID_PCM_S16LE;
     st->codec->sample_rate     = 44100;
     st->codec->channels        = 2;
     if (s->drive->audio_last_sector != CDIO_INVALID_LSN &&
@@ -92,12 +97,12 @@ static av_cold int read_header(AVFormatContext *ctx, AVFormatParameters *ap)
         st->duration           = s->drive->audio_last_sector - s->drive->audio_first_sector;
     else if (s->drive->tracks)
         st->duration = s->drive->disc_toc[s->drive->tracks].dwStartSector;
-    av_set_pts_info(st, 64, CDIO_CD_FRAMESIZE_RAW, 2*st->codec->channels*st->codec->sample_rate);
+    avpriv_set_pts_info(st, 64, CDIO_CD_FRAMESIZE_RAW, 2*st->codec->channels*st->codec->sample_rate);
 
     for (i = 0; i < s->drive->tracks; i++) {
         char title[16];
         snprintf(title, sizeof(title), "track %02d", s->drive->disc_toc[i].bTrack);
-        ff_new_chapter(ctx, i, st->time_base, s->drive->disc_toc[i].dwStartSector,
+        avpriv_new_chapter(ctx, i, st->time_base, s->drive->disc_toc[i].dwStartSector,
                        s->drive->disc_toc[i+1].dwStartSector, title);
     }
 
@@ -159,11 +164,11 @@ static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp,
 #define OFFSET(x) offsetof(CDIOContext, x)
 #define DEC AV_OPT_FLAG_DECODING_PARAM
 static const AVOption options[] = {
-    { "speed",              "Drive reading speed.", OFFSET(speed),         FF_OPT_TYPE_INT,   { 0 }, 0,       INT_MAX, DEC },
-    { "paranoia_mode",      "Error recovery mode.", OFFSET(paranoia_mode), FF_OPT_TYPE_FLAGS, { 0 }, INT_MIN, INT_MAX, DEC, "paranoia_mode" },
-        { "verify",         "Verify data integrity in overlap area", 0,    FF_OPT_TYPE_CONST, { PARANOIA_MODE_VERIFY },    0, 0, DEC, "paranoia_mode" },
-        { "overlap",        "Perform overlapped reads.",             0,    FF_OPT_TYPE_CONST, { PARANOIA_MODE_OVERLAP },   0, 0, DEC, "paranoia_mode" },
-        { "neverskip",      "Do not skip failed reads.",             0,    FF_OPT_TYPE_CONST, { PARANOIA_MODE_NEVERSKIP }, 0, 0, DEC, "paranoia_mode" },
+    { "speed",              "Drive reading speed.", OFFSET(speed),         AV_OPT_TYPE_INT,   { .i64 = 0 }, 0,       INT_MAX, DEC },
+    { "paranoia_mode",      "Error recovery mode.", OFFSET(paranoia_mode), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, DEC, "paranoia_mode" },
+        { "verify",         "Verify data integrity in overlap area", 0,    AV_OPT_TYPE_CONST, { .i64 = PARANOIA_MODE_VERIFY },    0, 0, DEC, "paranoia_mode" },
+        { "overlap",        "Perform overlapped reads.",             0,    AV_OPT_TYPE_CONST, { .i64 = PARANOIA_MODE_OVERLAP },   0, 0, DEC, "paranoia_mode" },
+        { "neverskip",      "Do not skip failed reads.",             0,    AV_OPT_TYPE_CONST, { .i64 = PARANOIA_MODE_NEVERSKIP }, 0, 0, DEC, "paranoia_mode" },
     { NULL },
 };