diff options
Diffstat (limited to 'src/codec/ffmpeg')
| -rw-r--r-- | src/codec/ffmpeg/avio.c | 10 | ||||
| -rw-r--r-- | src/codec/ffmpeg/common.c | 2 | ||||
| -rw-r--r-- | src/codec/ffmpeg/demuxer.c | 14 |
3 files changed, 18 insertions, 8 deletions
diff --git a/src/codec/ffmpeg/avio.c b/src/codec/ffmpeg/avio.c index 855a4de..154152e 100644 --- a/src/codec/ffmpeg/avio.c +++ b/src/codec/ffmpeg/avio.c @@ -2,10 +2,16 @@ #include "../../cache/handle.h" -s32 camu_avio_read(void *data, u8 *buf, s32 size) +s32 camu_avio_read(void *data, u8 *buf, s32 count) { struct cch_handle *handle = (struct cch_handle *)data; - return cch_handle_read(handle, buf, size); + return cch_handle_read(handle, buf, count); +} + +s32 camu_avio_write(void *data, const u8 *buf, s32 count) +{ + struct cch_handle *handle = (struct cch_handle *)data; + return cch_handle_write(handle, buf, count); } s64 camu_avio_seek(void *data, s64 offset, s32 whence) diff --git a/src/codec/ffmpeg/common.c b/src/codec/ffmpeg/common.c index d96dc76..259ba90 100644 --- a/src/codec/ffmpeg/common.c +++ b/src/codec/ffmpeg/common.c @@ -38,7 +38,7 @@ static void av_log_callback(void *userdata, s32 level, const char *fmt, va_list log_context.pos += ret; if ((log_context.pos > 0 && *(offset - 1) == '\n') || log_context.pos >= AV_LOG_MAX_CHUNK) { - if (level <= AV_LOG_INFO) { + if (level < AV_LOG_WARNING) { log_info(log_context.buf); } else { log_debug(log_context.buf); diff --git a/src/codec/ffmpeg/demuxer.c b/src/codec/ffmpeg/demuxer.c index d45a970..c5ca20c 100644 --- a/src/codec/ffmpeg/demuxer.c +++ b/src/codec/ffmpeg/demuxer.c @@ -95,7 +95,7 @@ static bool ff_demuxer_init(struct camu_demuxer *demux, struct cch_handle *handl if (stream->duration < 0) { stream->duration = av_rescale_q(default_duration, AV_TIME_BASE_Q, stream->time_base); al_assert(stream->duration >= 0); - log_warn("Stream #%u has an invalid duration, defaulting to %.3fs.", + log_debug("Stream #%u has an invalid duration, defaulting to %.3fs.", i, stream->duration * av_q2d(stream->time_base)); } duration = (u64)av_rescale_q(stream->duration, stream->time_base, AV_TIME_BASE_Q); @@ -162,19 +162,23 @@ static u64 ff_demuxer_get_duration(struct camu_demuxer *demux) return av->duration; } -static bool ff_demuxer_seek(struct camu_demuxer *demux, u64 pos) +static bool ff_demuxer_seek(struct camu_demuxer *demux, u64 pos, bool bytes) { struct camu_ff_demuxer *av = (struct camu_ff_demuxer *)demux; - al_assert(pos <= INT64_MAX); - if (pos > av->duration) pos = av->duration; if (av->eof) { // avio_flush() here probably does nothing. avio_flush(av->io_context); avformat_flush(av->format_context); av->eof = false; } + al_assert(pos <= INT64_MAX); + al_assert(!(bytes && av->format_context->flags & AVFMT_NO_BYTE_SEEK)); + if (!bytes && pos > av->duration) pos = av->duration; s64 ts = (s64)pos; - if (avformat_seek_file(av->format_context, -1, INT64_MIN, ts, ts, 0) < 0) { + s32 flags = bytes ? AVSEEK_FLAG_BYTE : 0; + s32 ret = avformat_seek_file(av->format_context, -1, INT64_MIN, ts, ts, flags); + if (ret < 0) { + log_error("Failed to seek resource (%s).", av_err2str(ret)); return false; } return true; |