X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Frpl.c;h=b72b8d0691e1180f17bab02e6602976a2655f662;hb=cc8db760616a7ec3bd39b22ca45888c01326db13;hp=62efafbd4b814ddd7df309a4e21a233f33b54d34;hpb=b8222b3d9c20f1d1abe5b0ec4e7efd08b7332f41;p=ffmpeg diff --git a/libavformat/rpl.c b/libavformat/rpl.c index 62efafbd4b8..b72b8d0691e 100644 --- a/libavformat/rpl.c +++ b/libavformat/rpl.c @@ -2,26 +2,30 @@ * ARMovie/RPL demuxer * Copyright (c) 2007 Christian Ohm, 2008 Eli Friedman * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * FFmpeg is distributed in the hope that it will be useful, + * Libav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include + #include "libavutil/avstring.h" +#include "libavutil/dict.h" #include "avformat.h" -#include +#include "internal.h" #define RPL_SIGNATURE "ARMovie\x0A" #define RPL_SIGNATURE_SIZE 8 @@ -47,11 +51,11 @@ typedef struct RPLContext { uint32_t frame_in_part; } RPLContext; -static int read_line(ByteIOContext * pb, char* line, int bufsize) +static int read_line(AVIOContext * pb, char* line, int bufsize) { int i; for (i = 0; i < bufsize - 1; i++) { - int b = get_byte(pb); + int b = avio_r8(pb); if (b == 0) break; if (b == '\n') { @@ -76,7 +80,7 @@ static int32_t read_int(const char* line, const char** endptr, int* error) return result; } -static int32_t read_line_and_int(ByteIOContext * pb, int* error) +static int32_t read_line_and_int(AVIOContext * pb, int* error) { char line[RPL_LINE_LENGTH]; const char *endptr; @@ -108,9 +112,9 @@ static AVRational read_fps(const char* line, int* error) return result; } -static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap) +static int rpl_read_header(AVFormatContext *s) { - ByteIOContext *pb = s->pb; + AVIOContext *pb = s->pb; RPLContext *rpl = s->priv_data; AVStream *vst = NULL, *ast = NULL; int total_audio_size; @@ -129,49 +133,47 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap) // number usually isn't important. // (The spec says that there exists some significance // for the text in a few cases; samples needed.) - error |= read_line(pb, line , sizeof(line )); // ARMovie + error |= read_line(pb, line, sizeof(line)); // ARMovie error |= read_line(pb, line, sizeof(line)); // movie name - av_metadata_set(&s->metadata, "title" , line); + av_dict_set(&s->metadata, "title" , line, 0); error |= read_line(pb, line, sizeof(line)); // date/copyright - av_metadata_set(&s->metadata, "copyright", line); + av_dict_set(&s->metadata, "copyright", line, 0); error |= read_line(pb, line, sizeof(line)); // author and other - av_metadata_set(&s->metadata, "author" , line); + av_dict_set(&s->metadata, "author" , line, 0); // video headers - vst = av_new_stream(s, 0); + vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); - vst->codec->codec_type = CODEC_TYPE_VIDEO; + vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_tag = read_line_and_int(pb, &error); // video format vst->codec->width = read_line_and_int(pb, &error); // video width vst->codec->height = read_line_and_int(pb, &error); // video height vst->codec->bits_per_coded_sample = read_line_and_int(pb, &error); // video bits per sample error |= read_line(pb, line, sizeof(line)); // video frames per second fps = read_fps(line, &error); - av_set_pts_info(vst, 32, fps.den, fps.num); + avpriv_set_pts_info(vst, 32, fps.den, fps.num); // Figure out the video codec switch (vst->codec->codec_tag) { #if 0 case 122: - vst->codec->codec_id = CODEC_ID_ESCAPE122; + vst->codec->codec_id = AV_CODEC_ID_ESCAPE122; break; #endif case 124: - vst->codec->codec_id = CODEC_ID_ESCAPE124; + vst->codec->codec_id = AV_CODEC_ID_ESCAPE124; // The header is wrong here, at least sometimes vst->codec->bits_per_coded_sample = 16; break; -#if 0 case 130: - vst->codec->codec_id = CODEC_ID_ESCAPE130; + vst->codec->codec_id = AV_CODEC_ID_ESCAPE130; break; -#endif default: av_log(s, AV_LOG_WARNING, "RPL video format %i not supported yet!\n", vst->codec->codec_tag); - vst->codec->codec_id = CODEC_ID_NONE; + vst->codec->codec_id = AV_CODEC_ID_NONE; } // Audio headers @@ -180,10 +182,10 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap) // samples, though. This code will ignore additional tracks. audio_format = read_line_and_int(pb, &error); // audio format ID if (audio_format) { - ast = av_new_stream(s, 0); + ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); - ast->codec->codec_type = CODEC_TYPE_AUDIO; + ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_tag = audio_format; ast->codec->sample_rate = read_line_and_int(pb, &error); // audio bitrate ast->codec->channels = read_line_and_int(pb, &error); // number of audio channels @@ -197,12 +199,12 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap) ast->codec->bits_per_coded_sample * ast->codec->channels; - ast->codec->codec_id = CODEC_ID_NONE; + ast->codec->codec_id = AV_CODEC_ID_NONE; switch (audio_format) { case 1: if (ast->codec->bits_per_coded_sample == 16) { // 16-bit audio is always signed - ast->codec->codec_id = CODEC_ID_PCM_S16LE; + ast->codec->codec_id = AV_CODEC_ID_PCM_S16LE; break; } // There are some other formats listed as legal per the spec; @@ -212,20 +214,20 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap) if (ast->codec->bits_per_coded_sample == 8) { // The samples with this kind of audio that I have // are all unsigned. - ast->codec->codec_id = CODEC_ID_PCM_U8; + ast->codec->codec_id = AV_CODEC_ID_PCM_U8; break; } else if (ast->codec->bits_per_coded_sample == 4) { - ast->codec->codec_id = CODEC_ID_ADPCM_IMA_EA_SEAD; + ast->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD; break; } break; } - if (ast->codec->codec_id == CODEC_ID_NONE) { + if (ast->codec->codec_id == AV_CODEC_ID_NONE) { av_log(s, AV_LOG_WARNING, - "RPL audio format %i not supported yet!\n", + "RPL audio format %"PRId32" not supported yet!\n", audio_format); } - av_set_pts_info(ast, 32, 1, ast->codec->bit_rate); + avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate); } else { for (i = 0; i < 3; i++) error |= read_line(pb, line, sizeof(line)); @@ -250,7 +252,7 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap) error |= read_line(pb, line, sizeof(line)); // offset to key frame list // Read the index - url_fseek(pb, chunk_catalog_offset, SEEK_SET); + avio_seek(pb, chunk_catalog_offset, SEEK_SET); total_audio_size = 0; for (i = 0; i < number_of_chunks; i++) { int64_t offset, video_size, audio_size; @@ -274,7 +276,7 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap) static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt) { RPLContext *rpl = s->priv_data; - ByteIOContext *pb = s->pb; + AVIOContext *pb = s->pb; AVStream* stream; AVIndexEntry* index_entry; uint32_t ret; @@ -292,18 +294,18 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt) index_entry = &stream->index_entries[rpl->chunk_number]; if (rpl->frame_in_part == 0) - if (url_fseek(pb, index_entry->pos, SEEK_SET) < 0) + if (avio_seek(pb, index_entry->pos, SEEK_SET) < 0) return AVERROR(EIO); - if (stream->codec->codec_type == CODEC_TYPE_VIDEO && + if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && stream->codec->codec_tag == 124) { // We have to split Escape 124 frames because there are // multiple frames per chunk in Escape 124 samples. - uint32_t frame_size, frame_flags; + uint32_t frame_size; - frame_flags = get_le32(pb); - frame_size = get_le32(pb); - if (url_fseek(pb, -8, SEEK_CUR) < 0) + avio_skip(pb, 4); /* flags */ + frame_size = avio_rl32(pb); + if (avio_seek(pb, -8, SEEK_CUR) < 0) return AVERROR(EIO); ret = av_get_packet(pb, pkt, frame_size); @@ -327,7 +329,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EIO); } - if (stream->codec->codec_type == CODEC_TYPE_VIDEO) { + if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO) { // frames_per_chunk should always be one here; the header // parsing will warn if it isn't. pkt->duration = rpl->frames_per_chunk; @@ -344,16 +346,16 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt) // None of the Escape formats have keyframes, and the ADPCM // format used doesn't have keyframes. if (rpl->chunk_number == 0 && rpl->frame_in_part == 0) - pkt->flags |= PKT_FLAG_KEY; + pkt->flags |= AV_PKT_FLAG_KEY; return ret; } -AVInputFormat rpl_demuxer = { - "rpl", - NULL_IF_CONFIG_SMALL("RPL/ARMovie format"), - sizeof(RPLContext), - rpl_probe, - rpl_read_header, - rpl_read_packet, +AVInputFormat ff_rpl_demuxer = { + .name = "rpl", + .long_name = NULL_IF_CONFIG_SMALL("RPL / ARMovie"), + .priv_data_size = sizeof(RPLContext), + .read_probe = rpl_probe, + .read_header = rpl_read_header, + .read_packet = rpl_read_packet, };