Re: [FFmpeg-devel] [PATCH] lavf/mov: initial support for reading HEIF images

2019-11-01 Thread Swaraj Hota
On Thu, Oct 31, 2019, 11:00 PM Dale Curtis  wrote:

> On Thu, Oct 31, 2019 at 1:32 AM Swaraj Hota 
> wrote:
>
> > Yes I will send the patch soon for review. Still a few things left to do.
> >
> > Swaraj
> >
>
> Great! Let me know if there's anything I can help with. If you need some
> AVIF samples they can be found here:
> https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/


Sure. Thanks for the samples!
I have not currently tested the patch with avif format, was only focused on
heif. But as the only difference is the decoder (?), this support could be
easily added. I'll try to add it but as I have been working on this for a
long time now, someone else can surely add it if I couldn't, after my patch
is merged that is.

Swaraj
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavf/mov: initial support for reading HEIF images

2019-10-31 Thread Swaraj Hota
On Thu, Oct 31, 2019, 4:39 AM Dale Curtis  wrote:

> On Wed, Oct 30, 2019 at 1:17 PM Carl Eugen Hoyos 
> wrote:
>
> > https://github.com/Swaraj1998/FFmpeg
> >
> > (Roger's patch sadly did not work with real-world files)
>
>
> Thanks Carl! That patch looks good. I'll test it out. Is Swaraj still
> planning to send that for review later?
>

Yes I will send the patch soon for review. Still a few things left to do.

Swaraj

>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6] avformat/ifv: added support for ifv cctv files

2019-06-16 Thread Swaraj Hota
On Sun, Jun 16, 2019 at 2:12 PM Paul B Mahol  wrote:

> On 6/16/19, Swaraj Hota  wrote:
> > On Sun 16 Jun, 2019, 8:24 AM Peter Ross,  wrote:
> >
> >> On Mon, Jun 10, 2019 at 09:25:27AM +0530, Swaraj Hota wrote:
> >> > Fixes ticket #2956.
> >> >
> >> > Signed-off-by: Swaraj Hota 
> >> > ---
> >> > Added entry in "doc/general.texi".
> >> > ---
> >> >  Changelog|   1 +
> >> >  doc/general.texi |   2 +
> >> >  libavformat/Makefile |   1 +
> >> >  libavformat/allformats.c |   1 +
> >> >  libavformat/ifv.c| 304
> +++
> >> >  libavformat/version.h|   4 +-
> >> >  6 files changed, 311 insertions(+), 2 deletions(-)
> >> >  create mode 100644 libavformat/ifv.c
> >>
> >> i think this is now ready to push.
> >>
> >> can you do that? if this for gsoc2019, does it first need blessing from
> >> mentor?
> >>
> >
> > I don't think that's required. ':D
>
> It is required, for sure. Mentor did not replied at all.
>

Sorry I didn't know that. But he did tell me before (personally) to get it
pushed iirc. I guess he is busy right now. Anyway, I think it would be fair
to wait for a few days and then push if no further objections?
Or if it is absolutely necessary then it's your call, we can wait for him.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6] avformat/ifv: added support for ifv cctv files

2019-06-16 Thread Swaraj Hota
On Sun 16 Jun, 2019, 8:24 AM Peter Ross,  wrote:

> On Mon, Jun 10, 2019 at 09:25:27AM +0530, Swaraj Hota wrote:
> > Fixes ticket #2956.
> >
> > Signed-off-by: Swaraj Hota 
> > ---
> > Added entry in "doc/general.texi".
> > ---
> >  Changelog|   1 +
> >  doc/general.texi |   2 +
> >  libavformat/Makefile |   1 +
> >  libavformat/allformats.c |   1 +
> >  libavformat/ifv.c| 304 +++
> >  libavformat/version.h|   4 +-
> >  6 files changed, 311 insertions(+), 2 deletions(-)
> >  create mode 100644 libavformat/ifv.c
>
> i think this is now ready to push.
>
> can you do that? if this for gsoc2019, does it first need blessing from
> mentor?
>

I don't think that's required. ':D

otherwise i will push in a couple of days.
>

Thank you!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v6] avformat/ifv: added support for ifv cctv files

2019-06-09 Thread Swaraj Hota
Fixes ticket #2956.

Signed-off-by: Swaraj Hota 
---
Added entry in "doc/general.texi".
---
 Changelog|   1 +
 doc/general.texi |   2 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/ifv.c| 304 +++
 libavformat/version.h|   4 +-
 6 files changed, 311 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/ifv.c

diff --git a/Changelog b/Changelog
index 1facc1fc46..8490f02d9f 100644
--- a/Changelog
+++ b/Changelog
@@ -31,6 +31,7 @@ version :
 - xmedian filter
 - asr filter
 - showspatial multimedia filter
+- IFV demuxer
 
 
 version 4.1:
diff --git a/doc/general.texi b/doc/general.texi
index ec437230e3..5143dc35c0 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -468,6 +468,8 @@ library:
 @item IEC61937 encapsulation @tab X @tab X
 @item IFF   @tab   @tab X
 @tab Interchange File Format
+@item IFV   @tab   @tab X
+@tab A format used by some old CCTV DVRs.
 @item iLBC  @tab X @tab X
 @item Interplay MVE @tab   @tab X
 @tab Format used in various Interplay computer games.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index df87c54a58..a434b005a4 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -231,6 +231,7 @@ OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
 OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
 OBJS-$(CONFIG_IDF_DEMUXER)   += bintext.o sauce.o
 OBJS-$(CONFIG_IFF_DEMUXER)   += iff.o
+OBJS-$(CONFIG_IFV_DEMUXER)   += ifv.o
 OBJS-$(CONFIG_ILBC_DEMUXER)  += ilbc.o
 OBJS-$(CONFIG_ILBC_MUXER)+= ilbc.o
 OBJS-$(CONFIG_IMAGE2_DEMUXER)+= img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d316a0529a..cd00834807 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -188,6 +188,7 @@ extern AVOutputFormat ff_ico_muxer;
 extern AVInputFormat  ff_idcin_demuxer;
 extern AVInputFormat  ff_idf_demuxer;
 extern AVInputFormat  ff_iff_demuxer;
+extern AVInputFormat  ff_ifv_demuxer;
 extern AVInputFormat  ff_ilbc_demuxer;
 extern AVOutputFormat ff_ilbc_muxer;
 extern AVInputFormat  ff_image2_demuxer;
diff --git a/libavformat/ifv.c b/libavformat/ifv.c
new file mode 100644
index 00..03c682bb9d
--- /dev/null
+++ b/libavformat/ifv.c
@@ -0,0 +1,304 @@
+/*
+ * IFV demuxer
+ *
+ * Copyright (c) 2019 Swaraj Hota
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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,
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "internal.h"
+#include "avio_internal.h"
+
+typedef struct IFVContext {
+uint32_t next_video_index;
+uint32_t next_audio_index;
+uint32_t total_vframes;
+uint32_t total_aframes;
+
+int width, height;
+int is_audio_present;
+int sample_rate;
+
+int video_stream_index;
+int audio_stream_index;
+} IFVContext;
+
+static int ifv_probe(const AVProbeData *p)
+{
+static const uint8_t ifv_magic[] = {0x11, 0xd2, 0xd3, 0xab, 0xba, 0xa9,
+0xcf, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65, 0x44};
+
+if (!memcmp(p->buf, ifv_magic, sizeof(ifv_magic)))
+return AVPROBE_SCORE_MAX;
+
+return 0;
+}
+
+static int read_index(AVFormatContext *s,
+  enum AVMediaType frame_type,
+  uint32_t start_index)
+{
+IFVContext *ifv = s->priv_data;
+AVStream *st;
+int64_t pos, size, timestamp;
+uint32_t end_index, i;
+int ret;
+
+if (frame_type == AVMEDIA_TYPE_VIDEO) {
+end_index = ifv->total_vframes;
+st = s->streams[ifv->video_stream_index];
+} else {
+end_index = ifv->total_aframes;
+st = s->streams[ifv->audio_stream_index];
+}
+
+for (i = start_index; i < end_index; i++) {
+pos = avio_rl32(s->pb);
+size = avio_rl32(s->pb);
+
+avio_skip(s->pb, 8);
+timestamp = avio_rl32(s->pb);
+
+ret = av_add_index_entry(st, pos, timestamp, size, 0, 0);
+if (ret < 0)
+return ret;
+
+avio_skip(s->pb, frame_type == AVMEDIA_TYPE_VIDEO ? 8: 4);
+}
+
+return 0;
+}

Re: [FFmpeg-devel] [PATCH v5] avformat/ifv: added support for ifv cctv files

2019-06-09 Thread Swaraj Hota
On Sun 9 Jun, 2019, 5:09 PM Peter Ross,  wrote:

> On Sun, Jun 09, 2019 at 09:36:33PM +1000, Peter Ross wrote:
> > On Mon, Jun 03, 2019 at 04:06:10AM +0530, Swaraj Hota wrote:
> > > On Sun, May 26, 2019 at 01:46:32AM +0530, Swaraj Hota wrote:
> > > > Fixes ticket #2956.
> > > >
> > > > Signed-off-by: Swaraj Hota 
> > > > ---
> > > > Minor changes based on previous discussions.
> > > > Seeking is fixed.
> > > > ---
> > > >  Changelog|   1 +
> > > >  libavformat/Makefile |   1 +
> > > >  libavformat/allformats.c |   1 +
> > > >  libavformat/ifv.c| 304
> +++
> > > >  libavformat/version.h|   4 +-
> > > >  5 files changed, 309 insertions(+), 2 deletions(-)
> > > >  create mode 100644 libavformat/ifv.c
> > > >
> > >
> > > Is the patch okay now? Can it be merged?
> >
> > i don't have any further comments. recommend commit.
>
> scrub that, an entry for the IFV format in missing in 'doc/general.texi'.
>

Sorry I didn't know it was required. I'll add that. Mention if any other
changes are required.

Thank you!

Swaraj
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v5] avformat/ifv: added support for ifv cctv files

2019-06-02 Thread Swaraj Hota
On Sun, May 26, 2019 at 01:46:32AM +0530, Swaraj Hota wrote:
> Fixes ticket #2956.
> 
> Signed-off-by: Swaraj Hota 
> ---
> Minor changes based on previous discussions.
> Seeking is fixed.
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/ifv.c| 304 +++
>  libavformat/version.h|   4 +-
>  5 files changed, 309 insertions(+), 2 deletions(-)
>  create mode 100644 libavformat/ifv.c
> 

Is the patch okay now? Can it be merged?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v5] avformat/ifv: added support for ifv cctv files

2019-05-31 Thread Swaraj Hota
On Thu, May 30, 2019 at 08:33:35PM +0200, Reimar Döffinger wrote:
> 
> 
> On 29.05.2019, at 19:51, Swaraj Hota  wrote:
> >> 
> >> Entirely depends on the purpose.
> >> If the aim is to have a working demuxer, I think it is acceptable from 
> >> what I looked at.
> >> I guess the only concern might be that not supporting piped input would be 
> >> a bit of a regression from the first patch.
> > 
> > Is there another simpler way to support piped input? Can you explain a
> > bit?
> 
> The mov demuxer code isn't really all that complicated.
> The basic idea is: if the input is not seekable, decided whether to read 
> audio or video based on which one has the lowest file position (a bit like 
> your original patch, but using it only for the "audio or video next" decision.
> If input is seekable, pick the stream with the lowest next timestamp as your 
> patch does now.
> It should be not that complicated in principle, but the details can make it a 
> pain sometimes.

Okay, I think I get the basic idea now. I will surely try to implement
this later in another patch. Thanx a lot!

Swaraj
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v5] avformat/ifv: added support for ifv cctv files

2019-05-29 Thread Swaraj Hota
On Tue, May 28, 2019 at 11:30:13PM +0200, Reimar Döffinger wrote:
> Hi!
> Did you intentionally not send to the list?

Okay I just realised I have been replying personally to all comments
whereas I should have sent them to the list ':D

> 
> On 28.05.2019, at 17:32, Swaraj Hota  wrote:
> 
> > On Sun, May 26, 2019 at 09:44:35PM +0200, Reimar Döffinger wrote:
> >> On Sun, May 26, 2019 at 01:46:32AM +0530, Swaraj Hota wrote:
> >>> +st = avformat_new_stream(s, NULL);
> >>> +if (!st)
> >>> +return AVERROR(ENOMEM);
> >>> +
> >>> +st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
> >>> +st->codecpar->codec_id = AV_CODEC_ID_H264;
> >>> +st->codecpar->width = ifv->width;
> >>> +st->codecpar->height = ifv->height;
> >>> +st->start_time = 0;
> >>> +ifv->video_stream_index = st->index;
> >> 
> >> I suspect that it would have been ok to
> >> just assume/assert this will always be 0.
> >> 
> > 
> > Okay, but I didn't get what exact change are you suggesting? Should 
> > I replace st->index with 0 here? Or should I get rid of
> > ifv->video/audio_stream_index variables and instead use 0 and 1
> > everywhere?
> 
> I think it's fine, now that you already wrote the code.
> Just saying that you probably didn't really have to implement quite as much.
> 

Will keep that in mind :)

> >>> +static int ifv_read_packet(AVFormatContext *s, AVPacket *pkt)
> >> 
> >> As far as I can tell, you just choose between audio
> >> and video by the closest timestamp.
> > 
> > Yes.
> > 
> >> While this might be ok considering the limited importance
> >> and uses of the format, it is rather simplistic.
> >> I do not know if it follows the latest best practices,
> >> but mov_find_next_sample is an example of a more
> >> sophisticated way.
> >> It takes into account whether the underlying transport
> >> has issues seeking (like http, or even worse piped input)
> >> and in that case prefers file position over timestamp
> >> position.
> >> It also avoids wasting time reading streams marked as
> >> AVDISCARD_ALL (in mov_read_packet is that check).
> >> Maybe others following the project more closely
> >> can give additional/better best practice tips.
> > 
> > Okay, I get that, but as you said considering the limited importance and
> > uses of the format, we must also consider if it is worth all the effort,
> > cuz it can also get more messy ':D Besides I have been working on this
> > format since over a month or two now, and understanding, writing and 
> > debugging 
> > this change might take quite some time ':D
> > 
> > I have been trying to comply with all good practices but I think a working 
> > demuxer is quite enough for a minority format like this (e.g. even the
> > dhav format is quite simplistic), but again I can't say that, 
> > if others agree that it is a necessity I will work on it.
> 
> Entirely depends on the purpose.
> If the aim is to have a working demuxer, I think it is acceptable from what I 
> looked at.
> I guess the only concern might be that not supporting piped input would be a 
> bit of a regression from the first patch.

Is there another simpler way to support piped input? Can you explain a
bit?

> If the aim is to learn and possibly tackle more involved formats it might be 
> useful. But even then maybe rather as a separate patch later...
> 

Actually another reason is that I now have to focus on my gsoc project,
so yeah, a separate patch later seems like a good idea to me :)

Thank you.

Swaraj
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5] avformat/ifv: added support for ifv cctv files

2019-05-25 Thread Swaraj Hota
Fixes ticket #2956.

Signed-off-by: Swaraj Hota 
---
Minor changes based on previous discussions.
Seeking is fixed.
---
 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/ifv.c| 304 +++
 libavformat/version.h|   4 +-
 5 files changed, 309 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/ifv.c

diff --git a/Changelog b/Changelog
index e6b209ae0a..e0b27657d7 100644
--- a/Changelog
+++ b/Changelog
@@ -30,6 +30,7 @@ version :
 - colorhold filter
 - xmedian filter
 - asr filter
+- IFV demuxer
 
 
 version 4.1:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index df87c54a58..a434b005a4 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -231,6 +231,7 @@ OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
 OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
 OBJS-$(CONFIG_IDF_DEMUXER)   += bintext.o sauce.o
 OBJS-$(CONFIG_IFF_DEMUXER)   += iff.o
+OBJS-$(CONFIG_IFV_DEMUXER)   += ifv.o
 OBJS-$(CONFIG_ILBC_DEMUXER)  += ilbc.o
 OBJS-$(CONFIG_ILBC_MUXER)+= ilbc.o
 OBJS-$(CONFIG_IMAGE2_DEMUXER)+= img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d316a0529a..cd00834807 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -188,6 +188,7 @@ extern AVOutputFormat ff_ico_muxer;
 extern AVInputFormat  ff_idcin_demuxer;
 extern AVInputFormat  ff_idf_demuxer;
 extern AVInputFormat  ff_iff_demuxer;
+extern AVInputFormat  ff_ifv_demuxer;
 extern AVInputFormat  ff_ilbc_demuxer;
 extern AVOutputFormat ff_ilbc_muxer;
 extern AVInputFormat  ff_image2_demuxer;
diff --git a/libavformat/ifv.c b/libavformat/ifv.c
new file mode 100644
index 00..03c682bb9d
--- /dev/null
+++ b/libavformat/ifv.c
@@ -0,0 +1,304 @@
+/*
+ * IFV demuxer
+ *
+ * Copyright (c) 2019 Swaraj Hota
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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,
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "internal.h"
+#include "avio_internal.h"
+
+typedef struct IFVContext {
+uint32_t next_video_index;
+uint32_t next_audio_index;
+uint32_t total_vframes;
+uint32_t total_aframes;
+
+int width, height;
+int is_audio_present;
+int sample_rate;
+
+int video_stream_index;
+int audio_stream_index;
+} IFVContext;
+
+static int ifv_probe(const AVProbeData *p)
+{
+static const uint8_t ifv_magic[] = {0x11, 0xd2, 0xd3, 0xab, 0xba, 0xa9,
+0xcf, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65, 0x44};
+
+if (!memcmp(p->buf, ifv_magic, sizeof(ifv_magic)))
+return AVPROBE_SCORE_MAX;
+
+return 0;
+}
+
+static int read_index(AVFormatContext *s,
+  enum AVMediaType frame_type,
+  uint32_t start_index)
+{
+IFVContext *ifv = s->priv_data;
+AVStream *st;
+int64_t pos, size, timestamp;
+uint32_t end_index, i;
+int ret;
+
+if (frame_type == AVMEDIA_TYPE_VIDEO) {
+end_index = ifv->total_vframes;
+st = s->streams[ifv->video_stream_index];
+} else {
+end_index = ifv->total_aframes;
+st = s->streams[ifv->audio_stream_index];
+}
+
+for (i = start_index; i < end_index; i++) {
+pos = avio_rl32(s->pb);
+size = avio_rl32(s->pb);
+
+avio_skip(s->pb, 8);
+timestamp = avio_rl32(s->pb);
+
+ret = av_add_index_entry(st, pos, timestamp, size, 0, 0);
+if (ret < 0)
+return ret;
+
+avio_skip(s->pb, frame_type == AVMEDIA_TYPE_VIDEO ? 8: 4);
+}
+
+return 0;
+}
+
+static int parse_header(AVFormatContext *s)
+{
+IFVContext *ifv = s->priv_data;
+uint32_t aud_magic;
+uint32_t vid_magic;
+
+avio_skip(s->pb, 0x5c);
+ifv->width = avio_rl16(s->pb);
+ifv->height = avio_rl16(s->pb);
+
+avio_skip(s->pb, 0x8);
+vid_magic = avio_rl32(s->pb);
+
+if (vid_magic != MKTAG('H','2','6','4'))
+avpriv_request_sample(s, "Unknown video codec %x", vid_magic);
+
+avio_skip(s->pb, 0x2c);
+ifv->sample_rate = avio_rl32(s->pb);
+aud_magic

[FFmpeg-devel] [PATCH v4] avformat/ifv: added support for ifv cctv files

2019-05-25 Thread Swaraj Hota
Fixes ticket #2956.

Signed-off-by: Swaraj Hota 
---
Changes made based on previous discussions.

Now the demuxer is working pretty much as the original dvr player does.
Framerate is based on timestamps (hence correct). Seeking is working for
all files without any issue.
---
 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/ifv.c| 318 +++
 libavformat/version.h|   4 +-
 5 files changed, 323 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/ifv.c

diff --git a/Changelog b/Changelog
index e6b209ae0a..e0b27657d7 100644
--- a/Changelog
+++ b/Changelog
@@ -30,6 +30,7 @@ version :
 - colorhold filter
 - xmedian filter
 - asr filter
+- IFV demuxer
 
 
 version 4.1:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index df87c54a58..a434b005a4 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -231,6 +231,7 @@ OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
 OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
 OBJS-$(CONFIG_IDF_DEMUXER)   += bintext.o sauce.o
 OBJS-$(CONFIG_IFF_DEMUXER)   += iff.o
+OBJS-$(CONFIG_IFV_DEMUXER)   += ifv.o
 OBJS-$(CONFIG_ILBC_DEMUXER)  += ilbc.o
 OBJS-$(CONFIG_ILBC_MUXER)+= ilbc.o
 OBJS-$(CONFIG_IMAGE2_DEMUXER)+= img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d316a0529a..cd00834807 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -188,6 +188,7 @@ extern AVOutputFormat ff_ico_muxer;
 extern AVInputFormat  ff_idcin_demuxer;
 extern AVInputFormat  ff_idf_demuxer;
 extern AVInputFormat  ff_iff_demuxer;
+extern AVInputFormat  ff_ifv_demuxer;
 extern AVInputFormat  ff_ilbc_demuxer;
 extern AVOutputFormat ff_ilbc_muxer;
 extern AVInputFormat  ff_image2_demuxer;
diff --git a/libavformat/ifv.c b/libavformat/ifv.c
new file mode 100644
index 00..517f0252f5
--- /dev/null
+++ b/libavformat/ifv.c
@@ -0,0 +1,318 @@
+/*
+ * IFV demuxer
+ *
+ * Copyright (c) 2019 Swaraj Hota
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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,
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "internal.h"
+#include "avio_internal.h"
+
+
+typedef struct IFVContext {
+uint32_t next_video_index;
+uint32_t next_audio_index;
+uint32_t total_vframes;
+uint32_t total_aframes;
+
+int width, height;
+int is_audio_present;
+int sample_rate;
+
+int video_stream_index;
+int audio_stream_index;
+} IFVContext;
+
+static int ifv_probe(const AVProbeData *p)
+{
+static const uint8_t ifv_magic[] = {0x11, 0xd2, 0xd3, 0xab, 0xba, 0xa9,
+0xcf, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65, 0x44};
+
+if (!memcmp(p->buf, ifv_magic, sizeof(ifv_magic)))
+return AVPROBE_SCORE_MAX;
+
+return 0;
+}
+
+static int read_index(AVFormatContext *s,
+  enum AVMediaType frame_type,
+  uint32_t start_index)
+{
+IFVContext *ifv = s->priv_data;
+AVStream *st;
+int64_t pos, size, timestamp;
+uint32_t end_index, i;
+int ret;
+
+if (frame_type == AVMEDIA_TYPE_VIDEO) {
+end_index = ifv->total_vframes;
+st = s->streams[ifv->video_stream_index];
+} else {
+end_index = ifv->total_aframes;
+st = s->streams[ifv->audio_stream_index];
+}
+
+for (i = start_index; i < end_index; i++) {
+pos = avio_rl32(s->pb);
+size = avio_rl32(s->pb);
+
+avio_skip(s->pb, 8);
+timestamp = avio_rl32(s->pb);
+
+ret = av_add_index_entry(st, pos, timestamp, size, 0, 0);
+if (ret < 0)
+return ret;
+
+avio_skip(s->pb, frame_type == AVMEDIA_TYPE_VIDEO? 8: 4);
+}
+
+return 0;
+}
+
+static int parse_header(AVFormatContext *s)
+{
+IFVContext *ifv = s->priv_data;
+uint32_t aud_magic;
+uint32_t vid_magic;
+
+avio_skip(s->pb, 0x5c);
+ifv->width = avio_rl16(s->pb);
+ifv->height = avio_rl16(s->pb);
+
+avio_skip(s->pb, 0x8);
+vid_magic = avio_rl32(s->pb);
+
+if (vid_magic != MKTAG('H','2','6','4'))
+avpriv_request_sam

Re: [FFmpeg-devel] [PATCH v3] avformat/ifv: added support for ifv cctv files

2019-05-20 Thread Swaraj Hota
On Thu 16 May, 2019, 2:19 AM Swaraj Hota,  wrote:

> Fixes ticket #2956.
>
> Signed-off-by: Swaraj Hota 
> ---
> Revised patch based on previous discussions.
> Some of the changes are:
> - using AVIndexEntry now
> - demuxer is totally index based (removed linear search)
> - added seeking functionality with timestamps
>
> There are some timing issues though, due to which seeking does not
> work in the files with audio (works fine for files without audio).
> I tried a lot but couldn't figure it out, maybe I don't understand
> timing stuff clearly. Any suggestions regarding this will be really
> helpful. Thanks in advance!
>
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/ifv.c| 316 +++
>  libavformat/version.h|   4 +-
>  5 files changed, 321 insertions(+), 2 deletions(-)
>  create mode 100644 libavformat/ifv.c


Ping!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3] avformat/ifv: added support for ifv cctv files

2019-05-15 Thread Swaraj Hota
Fixes ticket #2956.

Signed-off-by: Swaraj Hota 
---
Revised patch based on previous discussions.
Some of the changes are:
- using AVIndexEntry now
- demuxer is totally index based (removed linear search)
- added seeking functionality with timestamps 

There are some timing issues though, due to which seeking does not
work in the files with audio (works fine for files without audio).
I tried a lot but couldn't figure it out, maybe I don't understand
timing stuff clearly. Any suggestions regarding this will be really
helpful. Thanks in advance!

---
 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/ifv.c| 316 +++
 libavformat/version.h|   4 +-
 5 files changed, 321 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/ifv.c

diff --git a/Changelog b/Changelog
index e6b209ae0a..e0b27657d7 100644
--- a/Changelog
+++ b/Changelog
@@ -30,6 +30,7 @@ version :
 - colorhold filter
 - xmedian filter
 - asr filter
+- IFV demuxer
 
 
 version 4.1:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 99be60d184..f68d41e4a5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -231,6 +231,7 @@ OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
 OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
 OBJS-$(CONFIG_IDF_DEMUXER)   += bintext.o sauce.o
 OBJS-$(CONFIG_IFF_DEMUXER)   += iff.o
+OBJS-$(CONFIG_IFV_DEMUXER)   += ifv.o
 OBJS-$(CONFIG_ILBC_DEMUXER)  += ilbc.o
 OBJS-$(CONFIG_ILBC_MUXER)+= ilbc.o
 OBJS-$(CONFIG_IMAGE2_DEMUXER)+= img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d316a0529a..cd00834807 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -188,6 +188,7 @@ extern AVOutputFormat ff_ico_muxer;
 extern AVInputFormat  ff_idcin_demuxer;
 extern AVInputFormat  ff_idf_demuxer;
 extern AVInputFormat  ff_iff_demuxer;
+extern AVInputFormat  ff_ifv_demuxer;
 extern AVInputFormat  ff_ilbc_demuxer;
 extern AVOutputFormat ff_ilbc_muxer;
 extern AVInputFormat  ff_image2_demuxer;
diff --git a/libavformat/ifv.c b/libavformat/ifv.c
new file mode 100644
index 00..c834b3b63c
--- /dev/null
+++ b/libavformat/ifv.c
@@ -0,0 +1,316 @@
+/*
+ * IFV demuxer
+ *
+ * Copyright (c) 2019 Swaraj Hota
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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,
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "internal.h"
+#include "avio_internal.h"
+
+
+typedef struct IFVContext {
+uint32_t next_video_index;
+uint32_t next_audio_index;
+uint32_t total_vframes;
+uint32_t total_aframes;
+
+int width, height;
+int is_audio_present;
+int sample_rate;
+
+int video_stream_index;
+int audio_stream_index;
+} IFVContext;
+
+static int ifv_probe(const AVProbeData *p)
+{
+static const uint8_t ifv_magic[] = {0x11, 0xd2, 0xd3, 0xab, 0xba, 0xa9,
+0xcf, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65, 0x44};
+
+if (!memcmp(p->buf, ifv_magic, sizeof(ifv_magic)))
+return AVPROBE_SCORE_MAX;
+
+return 0;
+}
+
+static int read_index(AVFormatContext *s,
+  enum AVMediaType frame_type,
+  uint32_t start_index)
+{
+IFVContext *ifv = s->priv_data;
+AVStream *st;
+int64_t pos, size, timestamp;
+uint32_t end_index, i;
+int ret;
+
+if (frame_type == AVMEDIA_TYPE_VIDEO) {
+end_index = ifv->total_vframes;
+st = s->streams[ifv->video_stream_index];
+} else {
+end_index = ifv->total_aframes;
+st = s->streams[ifv->audio_stream_index];
+}
+
+for (i = start_index; i < end_index; i++) {
+pos = avio_rl32(s->pb);
+size = avio_rl32(s->pb);
+
+avio_skip(s->pb, 8);
+timestamp = avio_rl32(s->pb);
+
+ret = av_add_index_entry(st, pos, timestamp, size, 0, 0);
+if (ret < 0)
+return ret;
+
+avio_skip(s->pb, frame_type == AVMEDIA_TYPE_VIDEO? 8: 4);
+}
+
+return 0;
+}
+
+static int parse_header(AVFormatContext *s)
+{
+IFVContext *ifv = s->priv_data;
+uint32_t aud_magic;
+uint32

Re: [FFmpeg-devel] [PATCH v2] avformat/ifv: added support for ifv cctv files

2019-05-08 Thread Swaraj Hota
On Wed, May 08, 2019 at 09:28:33PM +0200, Reimar Döffinger wrote:
> On Wed, May 08, 2019 at 03:06:37PM +0530, Swaraj Hota wrote:
> > On Wed, May 08, 2019 at 12:52:01AM +0200, Reimar Döffinger wrote:
> > > First, seeking should be handled specially, by resetting the state.
> > > You should not make the get_packet less efficient because of that.
> > > That should enable the "remember last position and start from there".
> > >
> > > As to the corruption case, well the question is what to do about that, 
> > > and I don't have the answer.
> > > But if the solution were to e.g. ensure the frame offset is monotonous 
> > > then binary search could be used.
> > > However there is also the possibility that the format does in fact allow 
> > > a completely arbitrary order of frames in the file, maybe even re-using 
> > > an earlier frame_offset if the same frame appears multiple times.
> > > In that case this whole offset-based positioning code would simply be 
> > > wrong, and you'd have to store the current index position in your demuxer 
> > > instead of relying on avio_tell.
> > > Maybe you chose this solution because you did not know that seeking 
> > > should be implemented via special functions?
> >
> > By "special functions" do you mean those "read_seek" functions that
> > are present in many demuxers(Cuz I have not implemented that)?
> 
> Yes.
> 
> > If yes then am I mistaken that FFmpeg can also handle seeking
> > automatically? (Carl suggesting something like that, iirc)
> 
> It has some functionality, but I think in practice I don't think
> you can get a proper fully working solution with it.
> 
> > Keeping the corruption case aside, how do you suggest I implement this?
> > Is it not required to skip bytes till the next frame boundary in the
> > read_packet function (as done in the current patch) ?
> > If not then I guess I can go with a binary search, or better yet
> > remember the last position.
> 
> It's a bit more complex (in some aspect, simpler in others), but
> gxf.c might be an example.
> 
> I will describe what I think would be a correct full implementation,
> but I will also note that maybe this is asking a bit much.
> You would start with changing your index reading function to
> use av_add_index_entry instead of storing your own index.
> In read_packet you simply remember your position in that index and
> use that information to know where to read from the next time.
> This should work for linear playback.
> 
> Once that is done, read_seek would need implementing
> (it seems read_seek2 is currently only implemented by subtitle
> formats?).
> There you would seek the index for the right position
> (av_index_search_timestamp), and set the variables you
> use in read_packet accordingly so you will read the proper
> frames next.
> If the desired position is not in the index, you
> will also need to read the next index entries from
> the file (to start with you could do that by calling
> read_packet, even though it is a bit overkill).
> 
> Unfortunately this is all a bit complicated and a
> lot of things that need to be implemented right.
> The "quick fix" would be to implement a read_seek
> function that only returns -1, with that you
> continue to use the current seeking code, but
> it would allow you to tell the read_packet
> function to use the "search index position based
> on file position" code, whereas for normal
> playback you just continue reading whatever
> you stored as "next index position to read".
> 
> I'm sure far from everything I wrote is clear,
> but hopefully it gives you some starting points.
> 
> Best regards,
> Reimar Döffinger

That was really helpful! Thanks a lot!
It is more or less clear to me now. Okay then I will surely try the
"complicated" one first, and fallback to the "quick fix" otherwise.
Really sorry if I am asking a lot of questions here ':D

Swaraj
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] avformat/ifv: added support for ifv cctv files

2019-05-08 Thread Swaraj Hota
On Wed, May 08, 2019 at 12:52:01AM +0200, Reimar Döffinger wrote:
> On 07.05.2019, at 12:00, Swaraj Hota  wrote:
> 
> > On Sun, May 05, 2019 at 09:59:01PM +0200, Reimar Döffinger wrote:
> >> 
> >> 
> >>> +/*read video index*/
> >>> +avio_seek(s->pb, 0xf8, SEEK_SET);
> >> [...]
> >>> +avio_skip(s->pb, ifv->vid_index->frame_offset - avio_tell(s->pb));
> >> 
> >> Why use avio_seek in one place and avio_skip in the other?
> >> 
> > 
> > No particular reason. Essentially all are just skips. There is no
> > backward seek. I left two seeks becuase they seemed more readable.
> > Someone could know at a glance at what offset the first video and audio
> > index are assumed/found to be. Should I change them to skips as well?
> 
> Not quite sure how things work nowadays, but I'd suggest to use whichever
> gives the most readable code.
> Which would mean using avio_seek in this case.
> 
> >>> +pos = avio_tell(s->pb);
> >>> +
> >>> +for (i = 0; i < ifv->total_vframes; i++) {
> >>> +e = >vid_index[i];
> >>> +if (e->frame_offset >= pos)
> >>> +break;
> >>> +}
> >> 
> >> This looks rather inefficient.
> >> Wouldn't it make more sense to either
> >> use a binary search or at least to
> >> remember the position from the last read?
> >> This also does not seem very robust either,
> >> if a single frame_offset gets corrupted
> >> to a very large value, this code will
> >> never be able to find the "correct" position.
> >> It seems to assume the frame_offset
> >> is ordered increasingly (as would be needed for
> >> binary search), but that property isn't
> >> really checked/enforced.
> >> 
> > 
> > Yeah it is indeed inefficient. But it also seems like the "correct" one.
> > Because in case of seeking we might not be at the boundary of a frame
> > and hence might need to skip to the boundary of next frame we can find.
> > I guess this rules out binary search, and maybe also saving the last
> > read. 
> > 
> > Regarding the frame_offset corruption, well that rules out binary search
> > as well because then the order of the index will be disturbed.
> > 
> > Or maybe I misunderstood? Please do mention if this can be done more
> > efficiently by some method. I really need some ideas on this if it can
> > be done.
> 
> First, seeking should be handled specially, by resetting the state.
> You should not make the get_packet less efficient because of that.
> That should enable the "remember last position and start from there".
> 
> As to the corruption case, well the question is what to do about that, and I 
> don't have the answer.
> But if the solution were to e.g. ensure the frame offset is monotonous then 
> binary search could be used.
> However there is also the possibility that the format does in fact allow a 
> completely arbitrary order of frames in the file, maybe even re-using an 
> earlier frame_offset if the same frame appears multiple times.
> In that case this whole offset-based positioning code would simply be wrong, 
> and you'd have to store the current index position in your demuxer instead of 
> relying on avio_tell.
> Maybe you chose this solution because you did not know that seeking should be 
> implemented via special functions?

By "special functions" do you mean those "read_seek" functions that
are present in many demuxers(Cuz I have not implemented that)? 
If yes then am I mistaken that FFmpeg can also handle seeking
automatically? (Carl suggesting something like that, iirc)

Keeping the corruption case aside, how do you suggest I implement this?
Is it not required to skip bytes till the next frame boundary in the
read_packet function (as done in the current patch) ?
If not then I guess I can go with a binary search, or better yet
remember the last position.

Thank you.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] avformat/ifv: added support for ifv cctv files

2019-05-07 Thread Swaraj Hota
On Sun, May 05, 2019 at 09:59:01PM +0200, Reimar Döffinger wrote:
> Hello!
> Nothing major, but a few comments on things that might make
> sense to polish below.
> 
> On Sat, May 04, 2019 at 06:42:40PM +0530, Swaraj Hota wrote:
> > +#define IFV_MAGIC "\x11\xd2\xd3\xab\xba\xa9\xcf\x11\
> > +\x8e\xe6\x00\xc0\x0c\x20\x53\x65\x44"
> 
> > +if (!memcmp(p->buf, IFV_MAGIC, 17))
> 
> Using an array and sizeof() instead of the hard-coded 17 might be a bit
> nicer.
> 

That will be another way to do it. I'll change it then.

> > +int ret;
> > +
> > +if (frame_type == AVMEDIA_TYPE_VIDEO) {
> > +ret = av_reallocp_array(>vid_index, ifv->total_vframes, 
> > sizeof(IFVIndexEntry));
> > +if (ret < 0)
> > +return ret;
> > +
> > +} else if (frame_type == AVMEDIA_TYPE_AUDIO) {
> > +ret = av_reallocp_array(>aud_index, ifv->total_aframes, 
> > sizeof(IFVIndexEntry));
> > +if (ret < 0)
> > +return ret;
> > +}
> 
> Could just declare "ret" right where it is assigned.
> 

Okay that could be done.

> 
> > +/*read video index*/
> > +avio_seek(s->pb, 0xf8, SEEK_SET);
> [...]
> > +avio_skip(s->pb, ifv->vid_index->frame_offset - avio_tell(s->pb));
> 
> Why use avio_seek in one place and avio_skip in the other?
> 

No particular reason. Essentially all are just skips. There is no
backward seek. I left two seeks becuase they seemed more readable.
Someone could know at a glance at what offset the first video and audio
index are assumed/found to be. Should I change them to skips as well?

> > +pos = avio_tell(s->pb);
> > +
> > +for (i = 0; i < ifv->total_vframes; i++) {
> > +e = >vid_index[i];
> > +if (e->frame_offset >= pos)
> > +break;
> > +}
> 
> This looks rather inefficient.
> Wouldn't it make more sense to either
> use a binary search or at least to
> remember the position from the last read?
> This also does not seem very robust either,
> if a single frame_offset gets corrupted
> to a very large value, this code will
> never be able to find the "correct" position.
> It seems to assume the frame_offset
> is ordered increasingly (as would be needed for
> binary search), but that property isn't
> really checked/enforced.
> 

Yeah it is indeed inefficient. But it also seems like the "correct" one.
Because in case of seeking we might not be at the boundary of a frame
and hence might need to skip to the boundary of next frame we can find.
I guess this rules out binary search, and maybe also saving the last
read. 

Regarding the frame_offset corruption, well that rules out binary search
as well because then the order of the index will be disturbed.

Or maybe I misunderstood? Please do mention if this can be done more
efficiently by some method. I really need some ideas on this if it can
be done.

> > +av_freep(>vid_index);
> > +if (ifv->is_audio_present)
> > +av_freep(>aud_index);
> 
> Shouldn't the if () be unnecessary?
> 

Yeah I guess it is unnecessary. I'll change it.


Thanks for the review!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] avformat/ifv: added support for ifv cctv files

2019-05-04 Thread Swaraj Hota
Okay. Thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2] avformat/ifv: added support for ifv cctv files

2019-05-04 Thread Swaraj Hota
Fixes ticket #2956.

Signed-off-by: Swaraj Hota 
---
Revised patch. Made some minor changes based on original player:
- Removed incorrect reading of frame_rate, instead frame rate
is kept fixed at 25 (seems like this value is always same).
- Added reading of frame width and height from input file.

---
 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/ifv.c| 335 +++
 libavformat/version.h|   4 +-
 5 files changed, 340 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/ifv.c

diff --git a/Changelog b/Changelog
index a3fa0c14a2..03d2a9db01 100644
--- a/Changelog
+++ b/Changelog
@@ -26,6 +26,7 @@ version :
 - lscr decoder
 - lagfun filter
 - asoftclip filter
+- IFV demuxer
 
 
 version 4.1:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 99be60d184..f68d41e4a5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -231,6 +231,7 @@ OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
 OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
 OBJS-$(CONFIG_IDF_DEMUXER)   += bintext.o sauce.o
 OBJS-$(CONFIG_IFF_DEMUXER)   += iff.o
+OBJS-$(CONFIG_IFV_DEMUXER)   += ifv.o
 OBJS-$(CONFIG_ILBC_DEMUXER)  += ilbc.o
 OBJS-$(CONFIG_ILBC_MUXER)+= ilbc.o
 OBJS-$(CONFIG_IMAGE2_DEMUXER)+= img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d316a0529a..cd00834807 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -188,6 +188,7 @@ extern AVOutputFormat ff_ico_muxer;
 extern AVInputFormat  ff_idcin_demuxer;
 extern AVInputFormat  ff_idf_demuxer;
 extern AVInputFormat  ff_iff_demuxer;
+extern AVInputFormat  ff_ifv_demuxer;
 extern AVInputFormat  ff_ilbc_demuxer;
 extern AVOutputFormat ff_ilbc_muxer;
 extern AVInputFormat  ff_image2_demuxer;
diff --git a/libavformat/ifv.c b/libavformat/ifv.c
new file mode 100644
index 00..f2d12b4fe7
--- /dev/null
+++ b/libavformat/ifv.c
@@ -0,0 +1,335 @@
+/*
+ * IFV demuxer
+ *
+ * Copyright (c) 2019 Swaraj Hota
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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,
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "internal.h"
+#include "avio_internal.h"
+
+#define IFV_MAGIC "\x11\xd2\xd3\xab\xba\xa9\xcf\x11\
+\x8e\xe6\x00\xc0\x0c\x20\x53\x65\x44"
+
+typedef struct IFVIndexEntry {
+uint32_t frame_offset;
+uint32_t frame_size;
+enum AVMediaType frame_type;
+} IFVIndexEntry;
+
+typedef struct IFVContext {
+IFVIndexEntry *vid_index;
+IFVIndexEntry *aud_index;
+uint32_t index_pos;
+uint32_t total_vframes;
+uint32_t total_aframes;
+
+int width, height;
+int is_audio_present;
+int sample_rate;
+
+int video_stream_index;
+int audio_stream_index;
+} IFVContext;
+
+static int ifv_probe(const AVProbeData *p)
+{
+if (!memcmp(p->buf, IFV_MAGIC, 17))
+return AVPROBE_SCORE_MAX;
+return 0;
+}
+
+static int read_next_index_entry(AVFormatContext *s, enum AVMediaType 
frame_type)
+{
+IFVContext *ifv = s->priv_data;
+IFVIndexEntry *e;
+
+if (frame_type == AVMEDIA_TYPE_VIDEO) {
+if (ifv->index_pos >= ifv->total_vframes)
+return 0;
+
+e = >vid_index[ifv->index_pos++];
+
+e->frame_offset = avio_rl32(s->pb);
+e->frame_size = avio_rl32(s->pb);
+e->frame_type = frame_type;
+
+avio_skip(s->pb, 20);
+
+} else if (frame_type == AVMEDIA_TYPE_AUDIO) {
+if (ifv->index_pos >= ifv->total_aframes)
+return 0;
+
+e = >aud_index[ifv->index_pos++];
+
+e->frame_offset = avio_rl32(s->pb);
+e->frame_size = avio_rl32(s->pb);
+e->frame_type = frame_type;
+
+avio_skip(s->pb, 16);
+}
+
+return 1;
+}
+
+static int read_index(AVFormatContext *s, enum AVMediaType frame_type)
+{
+IFVContext *ifv = s->priv_data;
+int ret;
+
+if (frame_type == AVMEDIA_TYPE_VIDEO) {
+ret = av_reallocp_array(>vid_index, ifv->total_vframes, 
sizeof(IFVIndexEntry));
+if (ret < 0)
+return ret;
+
+} else if

Re: [FFmpeg-devel] [PATCH] avformat/ifv: added support for ifv cctv files

2019-04-26 Thread Swaraj Hota
On Sat, Apr 20, 2019 at 05:44:40AM +0530, Swaraj Hota wrote:
> Fixes ticket #2956.
> 
> Signed-off-by: Swaraj Hota 
> ---
> I have tested it on all the samples provided in the ticket and
> it works for all of them.
> 
> Please comment.
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/ifv.c| 332 +++
>  libavformat/version.h|   4 +-
>  5 files changed, 337 insertions(+), 2 deletions(-)
>  create mode 100644 libavformat/ifv.c
> 
> diff --git a/Changelog b/Changelog
> index 5b2b1e5af4..2a48c6b284 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -24,6 +24,7 @@ version :
>  - KUX demuxer
>  - AV1 frame split bitstream filter
>  - lscr decoder
> +- IFV demuxer
> 
> 
>  version 4.1:
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 99be60d184..f68d41e4a5 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -231,6 +231,7 @@ OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
>  OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
>  OBJS-$(CONFIG_IDF_DEMUXER)   += bintext.o sauce.o
>  OBJS-$(CONFIG_IFF_DEMUXER)   += iff.o
> +OBJS-$(CONFIG_IFV_DEMUXER)   += ifv.o
>  OBJS-$(CONFIG_ILBC_DEMUXER)  += ilbc.o
>  OBJS-$(CONFIG_ILBC_MUXER)+= ilbc.o
>  OBJS-$(CONFIG_IMAGE2_DEMUXER)+= img2dec.o img2.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index d316a0529a..cd00834807 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -188,6 +188,7 @@ extern AVOutputFormat ff_ico_muxer;
>  extern AVInputFormat  ff_idcin_demuxer;
>  extern AVInputFormat  ff_idf_demuxer;
>  extern AVInputFormat  ff_iff_demuxer;
> +extern AVInputFormat  ff_ifv_demuxer;
>  extern AVInputFormat  ff_ilbc_demuxer;
>  extern AVOutputFormat ff_ilbc_muxer;
>  extern AVInputFormat  ff_image2_demuxer;
> diff --git a/libavformat/ifv.c b/libavformat/ifv.c
> new file mode 100644
> index 00..dc871c5b44
> --- /dev/null
> +++ b/libavformat/ifv.c
> @@ -0,0 +1,332 @@
> +/*
> + * IFV demuxer
> + *
> + * Copyright (c) 2018 Swaraj Hota
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg 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,
> + * 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
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include "avformat.h"
> +#include "internal.h"
> +#include "avio_internal.h"
> +
> +#define IFV_MAGIC "\x11\xd2\xd3\xab\xba\xa9\xcf\x11\
> +\x8e\xe6\x00\xc0\x0c\x20\x53\x65\x44"
> +
> +typedef struct IFVIndexEntry {
> +uint32_t frame_offset;
> +uint32_t frame_size;
> +enum AVMediaType frame_type;
> +} IFVIndexEntry;
> +
> +typedef struct IFVContext {
> +IFVIndexEntry *vid_index;
> +IFVIndexEntry *aud_index;
> +uint32_t index_pos;
> +uint32_t total_vframes;
> +uint32_t total_aframes;
> +
> +int frame_rate;
> +int is_audio_present;
> +int sample_rate;
> +
> +int video_stream_index;
> +int audio_stream_index;
> +} IFVContext;
> +
> +static int ifv_probe(const AVProbeData *p)
> +{
> +if (!memcmp(p->buf, IFV_MAGIC, 17))
> +return AVPROBE_SCORE_MAX;
> +return 0;
> +}
> +
> +static int read_next_index_entry(AVFormatContext *s, enum AVMediaType 
> frame_type)
> +{
> +IFVContext *ifv = s->priv_data;
> +IFVIndexEntry *e;
> +
> +if (frame_type == AVMEDIA_TYPE_VIDEO) {
> +if (ifv->index_pos >= ifv->total_vframes)
> +return 0;
> +
> +e = >vid_index[ifv->index_pos++];
> +
> +e->frame_offset = avio_rl32(s->pb);
> +e->frame_size = avio_rl32(s->pb);
> +e->frame_type = frame_type;
> +
> +avio_skip(s->pb, 20);
> +
> +} else if (frame_type == AVMEDIA_TYPE_AUDIO) {
> +if (ifv->index_pos >= ifv->total_aframes)
> +  

[FFmpeg-devel] [PATCH] avformat/ifv: added support for ifv cctv files

2019-04-19 Thread Swaraj Hota
Fixes ticket #2956.

Signed-off-by: Swaraj Hota 
---
I have tested it on all the samples provided in the ticket and
it works for all of them.

Please comment.
---
 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/ifv.c| 332 +++
 libavformat/version.h|   4 +-
 5 files changed, 337 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/ifv.c

diff --git a/Changelog b/Changelog
index 5b2b1e5af4..2a48c6b284 100644
--- a/Changelog
+++ b/Changelog
@@ -24,6 +24,7 @@ version :
 - KUX demuxer
 - AV1 frame split bitstream filter
 - lscr decoder
+- IFV demuxer


 version 4.1:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 99be60d184..f68d41e4a5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -231,6 +231,7 @@ OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
 OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
 OBJS-$(CONFIG_IDF_DEMUXER)   += bintext.o sauce.o
 OBJS-$(CONFIG_IFF_DEMUXER)   += iff.o
+OBJS-$(CONFIG_IFV_DEMUXER)   += ifv.o
 OBJS-$(CONFIG_ILBC_DEMUXER)  += ilbc.o
 OBJS-$(CONFIG_ILBC_MUXER)+= ilbc.o
 OBJS-$(CONFIG_IMAGE2_DEMUXER)+= img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d316a0529a..cd00834807 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -188,6 +188,7 @@ extern AVOutputFormat ff_ico_muxer;
 extern AVInputFormat  ff_idcin_demuxer;
 extern AVInputFormat  ff_idf_demuxer;
 extern AVInputFormat  ff_iff_demuxer;
+extern AVInputFormat  ff_ifv_demuxer;
 extern AVInputFormat  ff_ilbc_demuxer;
 extern AVOutputFormat ff_ilbc_muxer;
 extern AVInputFormat  ff_image2_demuxer;
diff --git a/libavformat/ifv.c b/libavformat/ifv.c
new file mode 100644
index 00..dc871c5b44
--- /dev/null
+++ b/libavformat/ifv.c
@@ -0,0 +1,332 @@
+/*
+ * IFV demuxer
+ *
+ * Copyright (c) 2018 Swaraj Hota
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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,
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "internal.h"
+#include "avio_internal.h"
+
+#define IFV_MAGIC "\x11\xd2\xd3\xab\xba\xa9\xcf\x11\
+\x8e\xe6\x00\xc0\x0c\x20\x53\x65\x44"
+
+typedef struct IFVIndexEntry {
+uint32_t frame_offset;
+uint32_t frame_size;
+enum AVMediaType frame_type;
+} IFVIndexEntry;
+
+typedef struct IFVContext {
+IFVIndexEntry *vid_index;
+IFVIndexEntry *aud_index;
+uint32_t index_pos;
+uint32_t total_vframes;
+uint32_t total_aframes;
+
+int frame_rate;
+int is_audio_present;
+int sample_rate;
+
+int video_stream_index;
+int audio_stream_index;
+} IFVContext;
+
+static int ifv_probe(const AVProbeData *p)
+{
+if (!memcmp(p->buf, IFV_MAGIC, 17))
+return AVPROBE_SCORE_MAX;
+return 0;
+}
+
+static int read_next_index_entry(AVFormatContext *s, enum AVMediaType 
frame_type)
+{
+IFVContext *ifv = s->priv_data;
+IFVIndexEntry *e;
+
+if (frame_type == AVMEDIA_TYPE_VIDEO) {
+if (ifv->index_pos >= ifv->total_vframes)
+return 0;
+
+e = >vid_index[ifv->index_pos++];
+
+e->frame_offset = avio_rl32(s->pb);
+e->frame_size = avio_rl32(s->pb);
+e->frame_type = frame_type;
+
+avio_skip(s->pb, 20);
+
+} else if (frame_type == AVMEDIA_TYPE_AUDIO) {
+if (ifv->index_pos >= ifv->total_aframes)
+return 0;
+
+e = >aud_index[ifv->index_pos++];
+
+e->frame_offset = avio_rl32(s->pb);
+e->frame_size = avio_rl32(s->pb);
+e->frame_type = frame_type;
+
+avio_skip(s->pb, 16);
+}
+
+return 1;
+}
+
+static int read_index(AVFormatContext *s, enum AVMediaType frame_type)
+{
+IFVContext *ifv = s->priv_data;
+int ret;
+
+if (frame_type == AVMEDIA_TYPE_VIDEO) {
+ret = av_reallocp_array(>vid_index, ifv->total_vframes, 
sizeof(IFVIndexEntry));
+if (ret < 0)
+return ret;
+
+} else if (frame_type == AVMEDIA_TYPE_AUDIO) {
+ret = av_reallocp_array(>aud_index, ifv->total_aframes, 
sizeof(IFVIndexEntry));
+ 

Re: [FFmpeg-devel] [PATCH] avformat/flvdec: added support for KUX container

2019-03-23 Thread Swaraj Hota
Oh, I really wished to do it ':D
Anyway, thanks :) Tell me if any other change can be made.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/flvdec: added support for KUX container

2019-03-22 Thread Swaraj Hota
Okay I found "fmemopen()". I'll see if I can use it with
unzOpenCurrentFilePassword(). Please do tell if there
is a better solution though.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/flvdec: added support for KUX container

2019-03-22 Thread Swaraj Hota
I have the meta chunk loaded into a buffer.
I searched a lot but I couldn't find a way to decompress
a password protected zip buffer.

I saw zlib is used in the code base, so went through it.
Found a function "decompress()" but it didn't take a
password as argument. I found another function
under minizip/unzip.h called unzOpenCurrentFilePassword()
which does take password but it takes a file as an argument
and not a buffer.

I am not sure what to do. I thought of using mmap and pass
it to unzOpenCurrentFilePassword() but I guess its not
portable and might not work with windows. Or will it?
Please suggest something I can do here.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/flvdec: added support for KUX container

2019-03-21 Thread Swaraj Hota
The title is in unicode so I guess we can just encode it to utf8.
I can write a simple C code to do that.
What should I change in the patch though regarding this?
Can you give me more details on what exactly to implement?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/flvdec: added support for KUX container

2019-03-20 Thread Swaraj Hota
Okay, I found out the metadata block contains fields like:
logo (a url to thumbnail), tags (in Chinese), title (in Chinese as well),
and other information which mostly seem to be related to streaming.

I'm not sure though if anything is much useful. Please do suggest
if you think any of these can be used.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel