avformat/rpl: cosmetics

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
This commit is contained in:
Zane van Iperen 2021-05-04 21:59:37 +10:00
parent 3575a495f6
commit 2329f7f21e
No known key found for this signature in database
GPG Key ID: 68616B2D8AC4DCC5
1 changed files with 10 additions and 16 deletions

View File

@ -216,18 +216,13 @@ static int rpl_read_header(AVFormatContext *s)
if (ast->codecpar->bits_per_coded_sample == 16) { if (ast->codecpar->bits_per_coded_sample == 16) {
// 16-bit audio is always signed // 16-bit audio is always signed
ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
break;
} else if (ast->codecpar->bits_per_coded_sample == 8) { } else if (ast->codecpar->bits_per_coded_sample == 8) {
if(av_stristr(audio_type, "unsigned") != NULL) { if (av_stristr(audio_type, "unsigned") != NULL)
ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8; ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
break; else if (av_stristr(audio_type, "linear") != NULL)
} else if(av_stristr(audio_type, "linear") != NULL) {
ast->codecpar->codec_id = AV_CODEC_ID_PCM_S8; ast->codecpar->codec_id = AV_CODEC_ID_PCM_S8;
break; else
} else {
ast->codecpar->codec_id = AV_CODEC_ID_PCM_VIDC; ast->codecpar->codec_id = AV_CODEC_ID_PCM_VIDC;
break;
}
} }
// There are some other formats listed as legal per the spec; // There are some other formats listed as legal per the spec;
// samples needed. // samples needed.
@ -237,10 +232,8 @@ static int rpl_read_header(AVFormatContext *s)
// The samples with this kind of audio that I have // The samples with this kind of audio that I have
// are all unsigned. // are all unsigned.
ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8; ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
break;
} else if (ast->codecpar->bits_per_coded_sample == 4) { } else if (ast->codecpar->bits_per_coded_sample == 4) {
ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD; ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD;
break;
} }
break; break;
} }
@ -297,7 +290,8 @@ static int rpl_read_header(AVFormatContext *s)
total_audio_size += audio_size * 8; total_audio_size += audio_size * 8;
} }
if (error) return AVERROR(EIO); if (error)
return AVERROR(EIO);
return 0; return 0;
} }
@ -322,9 +316,10 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
index_entry = &stream->internal->index_entries[rpl->chunk_number]; index_entry = &stream->internal->index_entries[rpl->chunk_number];
if (rpl->frame_in_part == 0) if (rpl->frame_in_part == 0) {
if (avio_seek(pb, index_entry->pos, SEEK_SET) < 0) if (avio_seek(pb, index_entry->pos, SEEK_SET) < 0)
return AVERROR(EIO); return AVERROR(EIO);
}
if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
stream->codecpar->codec_tag == 124) { stream->codecpar->codec_tag == 124) {
@ -340,9 +335,9 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = av_get_packet(pb, pkt, frame_size); ret = av_get_packet(pb, pkt, frame_size);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (ret != frame_size) { if (ret != frame_size)
return AVERROR(EIO); return AVERROR(EIO);
}
pkt->duration = 1; pkt->duration = 1;
pkt->pts = index_entry->timestamp + rpl->frame_in_part; pkt->pts = index_entry->timestamp + rpl->frame_in_part;
pkt->stream_index = rpl->chunk_part; pkt->stream_index = rpl->chunk_part;
@ -356,9 +351,8 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = av_get_packet(pb, pkt, index_entry->size); ret = av_get_packet(pb, pkt, index_entry->size);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (ret != index_entry->size) { if (ret != index_entry->size)
return AVERROR(EIO); return AVERROR(EIO);
}
if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
// frames_per_chunk should always be one here; the header // frames_per_chunk should always be one here; the header