Message ID | bef6c3e4-1070-2752-5ddc-d14cf16f2aea@iitk.ac.in |
---|---|
State | New |
Headers | show |
maybe title should change from flv: Add XV (Xunlie Video) Support, Updated patch for ticket #3720 to flv: Add XV (Xunlei Video) Support, Updated patch for ticket #3720 Shivam Goyal <shivgo@iitk.ac.in> 于2019年4月9日周二 下午5:36写道: > > flv: Add XV (Xunlie Video) Support. > > Updated patch for ticket #3720. > > > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Steven Liu <lingjiujianke@gmail.com> 于2019年4月9日周二 下午5:46写道: > > maybe title should change from > flv: Add XV (Xunlie Video) Support, Updated patch for ticket #3720 > to > flv: Add XV (Xunlei Video) Support, Updated patch for ticket #3720 Ignore my comment please, the attachment file is correct. > > Shivam Goyal <shivgo@iitk.ac.in> 于2019年4月9日周二 下午5:36写道: > > > > flv: Add XV (Xunlie Video) Support. > > > > Updated patch for ticket #3720. > > > > > > > > > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
2019-04-09 11:36 GMT+02:00, Shivam Goyal <shivgo@iitk.ac.in>: > flv: Add XV (Xunlie Video) Support. > > Updated patch for ticket #3720. Above is an acceptable commit message, slightly better would be: " lavf/flv: Add XV (Xunlie Video) Support. Fixes ticket #3720. " I applied your patch with git am and what I get as commit message is: Updated patch for ticket #3720. flv: Add XV (Xunlei Video) support This is not ok. The following probably doesn't work for some very large files: > + offset = ((avio_r8(ic) + rot & 0xff)<<24) | > + ((avio_r8(ic) + rot & 0xff)<<16) | > + ((avio_r8(ic) + rot & 0xff)<<8) | > + ((avio_r8(ic) + rot & 0xff)) + 0x200000; I suggested: offset = ((avio_r8(ic) + rot & 0xff) << 24 | (avio_r8(ic) + rot & 0xff) << 16) | (avio_r8(ic) + rot & 0xff) << 8) | (avio_r8(ic) + rot & 0xff)) + 0x200000; There are still "for(" that should be "for (", "if(" that should be "if (" and "+ rot )" that should be "+ rot)" (or no parentheses). The script tools/patcheck should find them, it will also tell you to add a line to Changelog and bump libavformat minor version. Carl Eugen
On 4/9/19 5:10 PM, Carl Eugen Hoyos wrote: > 2019-04-09 11:36 GMT+02:00, Shivam Goyal <shivgo@iitk.ac.in>: >> flv: Add XV (Xunlie Video) Support. >> >> Updated patch for ticket #3720. > Above is an acceptable commit message, slightly > better would be: > " > lavf/flv: Add XV (Xunlie Video) Support. > > Fixes ticket #3720. > " > I applied your patch with git am and what I get as commit > message is: > Updated patch for ticket #3720. flv: Add XV (Xunlei Video) support > > This is not ok. > > The following probably doesn't work for some very large files: > >> + offset = ((avio_r8(ic) + rot & 0xff)<<24) | >> + ((avio_r8(ic) + rot & 0xff)<<16) | >> + ((avio_r8(ic) + rot & 0xff)<<8) | >> + ((avio_r8(ic) + rot & 0xff)) + 0x200000; > I suggested: > offset = ((avio_r8(ic) + rot & 0xff) << 24 | > (avio_r8(ic) + rot & 0xff) << 16) | > (avio_r8(ic) + rot & 0xff) << 8) | > (avio_r8(ic) + rot & 0xff)) + 0x200000; The suggested notation is wrong, are you want to suggest ? offset =((avio_r8(ic) +rot &0xff) <<24| (avio_r8(ic) +rot &0xff) <<16| (avio_r8(ic) +rot &0xff) <<8| (avio_r8(ic) +rot &0xff)) +0x200000; > > There are still "for(" that should be "for (", "if(" that should be "if (" > and "+ rot )" that should be "+ rot)" (or no parentheses). > The script tools/patcheck should find them, it will also tell you > to add a line to Changelog and bump libavformat minor version. > > Carl Eugen > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
2019-04-09 15:26 GMT+02:00, Shivam Goyal <shivgo@iitk.ac.in>: > > On 4/9/19 5:10 PM, Carl Eugen Hoyos wrote: >> 2019-04-09 11:36 GMT+02:00, Shivam Goyal <shivgo@iitk.ac.in>: >> The following probably doesn't work for some very large files: >> >>> + offset = ((avio_r8(ic) + rot & 0xff)<<24) | >>> + ((avio_r8(ic) + rot & 0xff)<<16) | >>> + ((avio_r8(ic) + rot & 0xff)<<8) | >>> + ((avio_r8(ic) + rot & 0xff)) + 0x200000; > > >> I suggested: >> offset = ((avio_r8(ic) + rot & 0xff) << 24 | >> (avio_r8(ic) + rot & 0xff) << 16) | >> (avio_r8(ic) + rot & 0xff) << 8) | >> (avio_r8(ic) + rot & 0xff)) + 0x200000; > > The suggested notation is wrong True, sorry. offset = ((avio_r8(ic) + rot & 0xff) << 24 | (avio_r8(ic) + rot & 0xff) << 16 | (avio_r8(ic) + rot & 0xff) << 8 | (avio_r8(ic) + rot & 0xff)) + 0x200000; Carl Eugen
From 4e976186059b0fc41de7b65f538c352d264477d4 Mon Sep 17 00:00:00 2001 From: Shivam Goyal <shivgo@iitk.ac.in> Date: Tue, 9 Apr 2019 15:00:49 +0530 Subject: [PATCH] Updated patch for ticket #3720. flv: Add XV (Xunlei Video) support --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/flvdec.c | 85 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/libavformat/Makefile b/libavformat/Makefile index 99be60d184..e090c051f1 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -561,6 +561,7 @@ OBJS-$(CONFIG_WV_MUXER) += wvenc.o wv.o apetag.o img2.o OBJS-$(CONFIG_XA_DEMUXER) += xa.o OBJS-$(CONFIG_XBIN_DEMUXER) += bintext.o sauce.o OBJS-$(CONFIG_XMV_DEMUXER) += xmv.o +OBJS-$(CONFIG_XV_DEMUXER) += flvdec.o OBJS-$(CONFIG_XVAG_DEMUXER) += xvag.o OBJS-$(CONFIG_XWMA_DEMUXER) += xwma.o OBJS-$(CONFIG_YOP_DEMUXER) += yop.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index d316a0529a..b499186071 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -456,6 +456,7 @@ extern AVOutputFormat ff_wv_muxer; extern AVInputFormat ff_xa_demuxer; extern AVInputFormat ff_xbin_demuxer; extern AVInputFormat ff_xmv_demuxer; +extern AVInputFormat ff_xv_demuxer; extern AVInputFormat ff_xvag_demuxer; extern AVInputFormat ff_xwma_demuxer; extern AVInputFormat ff_yop_demuxer; diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index b531a39adc..2bbf2e3b1c 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -127,6 +127,19 @@ static int kux_probe(const AVProbeData *p) return 0; } +static int xv_probe(const AVProbeData *p) +{ + const uint8_t *d = p->buf; + + if (d[0] == 'X' && + d[1] == 'L' && + d[2] == 'V' && + d[3] == 'F') { + return AVPROBE_SCORE_EXTENSION + 1; + } + return 0; +} + static void add_keyframes_index(AVFormatContext *s) { FLVContext *flv = s->priv_data; @@ -459,6 +472,12 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m } } + if(!strcmp(s->iformat->name , "xv")){ + for (i=0; i < FFMIN(2,fileposlen); i++){ + filepositions[i] += 0x200000; + } + } + if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) { for (i = 0; i < FFMIN(2,fileposlen); i++) { flv->validate_index[i].pos = filepositions[i]; @@ -783,6 +802,51 @@ static int flv_read_header(AVFormatContext *s) return 0; } +static int xv_read_header(AVFormatContext *s) +{ + int flags; + FLVContext *xv = s->priv_data; + AVIOContext *ic = s->pb; + int offset; + int rot; + int64_t pos; + + //Find the rot value for rotating the bytes + avio_skip(ic, 0x200000); + rot = 0x46 - avio_r8(ic); + + avio_skip(ic, 3); + + flags = (avio_r8(ic) + rot ) & 0xff; + + xv->missing_streams = flags & (FLV_HEADER_FLAG_HASVIDEO | FLV_HEADER_FLAG_HASAUDIO); + + s->ctx_flags |= AVFMTCTX_NOHEADER; + + offset = ((avio_r8(ic) + rot & 0xff)<<24) | + ((avio_r8(ic) + rot & 0xff)<<16) | + ((avio_r8(ic) + rot & 0xff)<<8) | + ((avio_r8(ic) + rot & 0xff)) + 0x200000; + + avio_seek(ic, offset + 4, SEEK_SET); + + + // Will modify the current buffer, as only + // the bytes from 0x200000 to 0x200400 are needed to decode + pos = ic->pos + ic->buf_ptr - ic->buf_end; + for(int i = 0; i < 0x400; i++){ + if(pos >= 0x200400) break; + ic->buf_ptr[i] = (ic->buf_ptr[i] + rot) & 0xff; + pos++; + } + + s->start_time = 0; + xv->sum_flv_tag_size = 0; + xv->last_keyframe_stream_index = -1; + + return 0; +} + static int flv_read_close(AVFormatContext *s) { int i; @@ -1424,3 +1488,24 @@ AVInputFormat ff_kux_demuxer = { .extensions = "kux", .priv_class = &kux_class, }; + +static const AVClass xv_class = { + .class_name = "xvdec", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVInputFormat ff_xv_demuxer = { + .name = "xv", + .long_name = NULL_IF_CONFIG_SMALL("Xunlei(Thunder) Video File"), + .priv_data_size = sizeof(FLVContext), + .read_probe = xv_probe, + .read_header = xv_read_header, + .read_packet = flv_read_packet, + .read_seek = flv_read_seek, + .read_close = flv_read_close, + .extensions = "xv", + .priv_class = &xv_class, + .flags = AVFMT_TS_DISCONT +}; \ No newline at end of file -- 2.21.0