[Libav-user] Demuxer not giving proper data to decoder ?

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] Demuxer not giving proper data to decoder ?

ssshukla26
I have added support for one of our custom decoder (with id AV_CODEC_ID_H264) in ffmpeg source, and its working fine with h264 and mp4 files.

When playing mp4 file am seeing macroblocks artefact. So debugging further, I dump the in-coming packets from demuxer before decoding and found that the packets itself contains macro blocks artefact.

So am very very confuse, why demuxer is outputting data with macro blocks artefact !

Please help.
Regards, Sunny.
Reply | Threaded
Open this post in threaded view
|

Re: [Libav-user] Demuxer not giving proper data to decoder ?

ssshukla26
After debugging, I realized that my decoder is getting data in AVCC format, so on application side I added bit stream filter "h264_mp4toannexb" and everything worked. No artefacts at all.

So to make sure that my decoder use data in AnnexB format, I added h264_mp4toannexb filter inside decoder, filtering the incoming packet data, so I don't have to change anything on application side. But I am getting the below error.


"Packet header is not contained in global extradata, corrupted stream or invalid MP4/AVCC bitstream"

Please help.


Regards, Sunny.
Reply | Threaded
Open this post in threaded view
|

Re: Demuxer not giving proper data to decoder ?

Carl Eugen Hoyos-2
2016-09-15 11:05 GMT+02:00 ssshukla26 <[hidden email]>:
> After debugging, I realized that my decoder is getting data in *AVCC*
> format, so on application side I added bit stream filter
> "*h264_mp4toannexb*" and everything worked.

Which decoder are you using?
There should be no bitstream filter needed for FFmpeg decoder afair.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: Demuxer not giving proper data to decoder ?

ssshukla26
I have made a custom decoder with name "h264_qhw" and id "AV_CODEC_ID_H264".

I also agree with you, that a decoder must not need any filter, if and only if it receives proper demuxed data. But here weirdly the decoder is receiving data in AVCC format instead of proper Annexb format !

What is needed to be done to make sure that my decoder will receive proper demuxed data ?
Regards, Sunny.
Reply | Threaded
Open this post in threaded view
|

Re: Demuxer not giving proper data to decoder ?

Carl Eugen Hoyos-2
2016-09-15 13:10 GMT+02:00 ssshukla26 <[hidden email]>:
> I have made a custom decoder with name "*h264_qhw*" and id
> "*AV_CODEC_ID_H264*".

What happens if you test your code (without the bitstream filter)
with the existing software decoder?

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: Demuxer not giving proper data to decoder ?

ssshukla26
It runs properly, with "h264" (default) software decoder without using bit stream filter.

Which makes me believe that I must be missing something in configuring decoder to receive proper demuxed data, but I dont know what I am missing !
Regards, Sunny.
Reply | Threaded
Open this post in threaded view
|

Re: Demuxer not giving proper data to decoder ?

Carl Eugen Hoyos-2
2016-09-15 13:19 GMT+02:00 ssshukla26 <[hidden email]>:
> It runs properly, with "*h264*" (default) software decoder without using bit
> stream filter.
>
> Which makes me believe that I must be missing something in configuring
> decoder to receive proper demuxed data, but I dont know what I am missing !

Do I understand correctly that your hardware decoder only accepts
data in Annex B format, not in avcC? I suspect this is also true for
other hardware decoders already in FFmpeg, check what they do.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: Demuxer not giving proper data to decoder ?

ssshukla26
Yup. that's true.

But I don't understand one thing, my decoder is working properly with a h264 file in proper AnnexB data format, and when using mp4 file which is in AVCC format, the demuxing which should take place is not taking place at all ! Does that mean I need to configure the demuxer with my decoder or something like that ?
Regards, Sunny.
Reply | Threaded
Open this post in threaded view
|

Re: Demuxer not giving proper data to decoder ?

Carl Eugen Hoyos-2
2016-09-15 13:30 GMT+02:00 ssshukla26 <[hidden email]>:
> But I don't understand one thing, my decoder is working properly
> with a *h264* file in proper AnnexB data format, and when using
> *mp4* file which is in AVCC format, the demuxing which should take
> place is not taking place at all !

I may misunderstand you but I (strongly) suspect it is not the
> demuxers job to mess with video data.

Again:
Please look at what other existing hardware decoders in FFmpeg do.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: Demuxer not giving proper data to decoder ?

ssshukla26
Ok. I might be wrong, but the demuxers are only for extracting data out of the container ! Right ?

So If that the case, any decoder will receive data in AVCC format when mp4 files are used as input ?

So one must convert data from avcc to annexb format under the decoder ?
Regards, Sunny.
Reply | Threaded
Open this post in threaded view
|

Re: Demuxer not giving proper data to decoder ?

Carl Eugen Hoyos-2
2016-09-15 13:41 GMT+02:00 ssshukla26 <[hidden email]>:

[...]

Did you already look at other hardware decoders in current FFmpeg?

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: Demuxer not giving proper data to decoder ?

ssshukla26
Solved it by following code under decode function of decoder.


if(av_bitstream_filter_filter(decoder->bsf, avctx, "private_spspps_buf",
                                        &decoder->pkt.data, &decoder->pkt.size,
                                        avpkt->data, avpkt->size, !!(avpkt->flags & AV_PKT_FLAG_KEY)) < 0)
{
    ERROR("Error: unable to convert data from avcc to annexb");
}
else
{
    //Do decoding of decoder->pkt.data instead of avpkt->data
}
Regards, Sunny.
Reply | Threaded
Open this post in threaded view
|

Re: Demuxer not giving proper data to decoder ?

ssshukla26
under ./libavcodec/hevc_mp4toannexb_bsf.c there is note as below.

When private_spspps is zero then spspps_buf points to global extradata and bsf does replace a global extradata to own-allocated version (default behaviour).

When private_spspps is non-zero the bsf uses a private version of spspps buf. This mode necessary when bsf uses in decoder, else bsf has issues after decoder re-initialization. Use the "private_spspps_buf" argument to activate this mode.
Regards, Sunny.
Reply | Threaded
Open this post in threaded view
|

Re: Demuxer not giving proper data to decoder ?

Carl Eugen Hoyos-2
In reply to this post by Carl Eugen Hoyos-2
2016-09-15 13:54 GMT+02:00 Carl Eugen Hoyos <[hidden email]>:
> 2016-09-15 13:41 GMT+02:00 ssshukla26 <[hidden email]>:
>
> [...]
>
> Did you already look at other hardware decoders in current FFmpeg?

You may be interested to see this patch on -devel:

crystalhd: Use up-to-date bsf API
http://ffmpeg.org/pipermail/ffmpeg-devel/2016-September/199734.html

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user