[mythtv] Another ffmpeg mediacodec problem

Peter Bennett pb.mythtv at gmail.com
Wed Sep 26 19:23:21 UTC 2018


Hi Aman

I redid the patch to match the way you previously patched for the shield 
(see attached).

There is a strange thing that I have found: Playback using ffmpeg 
mediacodec and using ffmpeg software decoding appear to be the same. I 
see the same performance from both. It appears that the fire stick does 
not have an mpeg coprocessor but just decodes everything with software. 
mpeg2, h264 and h265 all play equally well with software decoding 
(except that mpeg2 through software decoding correctly detects the 
interlace and the deinterlacing then affects performance). Playback is 
still jerky and I plan to look into fixing that.

So maybe we should just use software decoding for this device.

Peter


On 09/25/2018 11:10 AM, Peter Bennett wrote:
> Hi Aman
>
> Thank you for the reply
>
> On 09/24/2018 04:29 PM, Aman Gupta wrote:
>> Hi Peter,
>>
>> Did you see my version of the shield fix patch? You should be doing 
>> something similar and not changing slice_height usage.
>>
>> https://patchwork.ffmpeg.org/patch/9853/
>>
> Yes - looked at that. In the NVidia case it looks like slice height 
> was passed in as zero, and you added code to fix it. In the fire stick 
> case the slice height is passed in but is the wrong value, i.e. it 
> gets a value of 1088 but it actually should be 1080. I would have to 
> put a check in mediacodecdec_common.c for the specific codec name 
> OMX.MTK.VIDEO.DECODER.MPEG2 (or starts with OMX.MTK.). However I am a 
> bit concerned - putting in a correct value when 0 is given makes 
> sense, but changing a value that was supplied seems suspect. I wonder 
> if there is a bug in the mediacodec implementation on the fire stick. 
> (see below the format string).
>
>> As far as detecting interlacing, there is no way to do that apart 
>> from checking the android device model and hardcoding what is 
>> expected. In my experience the fire stick is not powerful enough to 
>> do any type of deinterlacing. Let me know if you have different results.
>>
> We have some OpenGL deinterlacers, but my experience testing on the 
> fire stick is that they are slowing things down, so confirming your 
> statement. I thought to try playing around with them to see if I could 
> get some simplified deinterlace to work. However if I cannot tell 
> interlaced from progressive, it may not be useful to even try it.
>
> Peter
>> Aman
>> On Mon, Sep 24, 2018 at 8:35 AM Peter Bennett <pb.mythtv at gmail.com 
>> <mailto:pb.mythtv at gmail.com>> wrote:
>>
>>     Hi Aman
>>
>>     mediacodec is working well with the shield now. I am now testing
>>     Mythfrontend with another android device (amazon fire stick). The
>>     amazon fire stick runs amazon's version of android, which is
>>     built on android 5.1.
>>     Playback is working quite well on the fire stick, except for
>>     1080i mpeg2 content.
>>     _
>>     Problem 1_
>>     There is a problem very similar to the one we had on the shield.
>>     This time there is no seg fault, but the color is shifted upward
>>     on the screen.
>>     In this case it is using
>>     ff_mediacodec_sw_buffer_copy_yuv420_planar, so there are three
>>     planes. The slice height is 1088. The same patch as before works,
>>     i.e. change the code to use the height (1080) instead of the
>>     slice height fixes the problem. Patch file is attached. For
>>     photos of the screen see below URLs.
>>
>>     Corrupted picture https://imagebin.ca/v/4GogJVTUFY72
>>     Picture after the patch https://imagebin.ca/v/4GogkMDmF7FU
>>
>>     The buffer size that is passed into
>>     ff_mediacodec_sw_buffer_copy_yuv420_planar is the correct size
>>     for if it was using a slice height of 1088. With the shield the
>>     buffer size was only enough for a slice height of 1080, which is
>>     why the shield got a seg fault when it tried to use 1088 as slice
>>     height.
>>     size passed in = 3133472
>>     Size needed for 1080 slice height: 1920*1080+960*540+960*540 =
>>     3110400
>>     Size needed for 1088 slice height: 1920*1088+960*544+960*544 =
>>     3133440
>>
>>     in mediacodec_dec_parse_format:
>>     (gdb) print s->codec_name
>>     $9 = 0xb84f51e0 "OMX.MTK.VIDEO.DECODER.MPEG2"
>>     (gdb) print format
>>     $20 = 0xb8582320
>>     "{image-data=java.nio.ByteArrayBuffer[position=0,limit=80,capacity=80],
>>     mime=video/raw, crop-top=0, crop-right=1919, slice-height=1088,
>>     color-format=19, height=1080, width=1920, crop-bottom=1079,
>>     crop-left=0, stride=1920}"
>>     _
>>     Problem 2_
>>     Also on the fire stick, with 480i or 1080i content,
>>     AVFrame::interlaced_frame is always 0. As a result we are not
>>     calling any deinterlacer. Can you help with how we can find out
>>     that frames are interlaced?
>>
>>
>>     Peter
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-dev/attachments/20180926/fffbbbc4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20180926_1511_ffmpeg_fire.patch
Type: text/x-patch
Size: 726 bytes
Desc: not available
URL: <http://lists.mythtv.org/pipermail/mythtv-dev/attachments/20180926/fffbbbc4/attachment.bin>


More information about the mythtv-dev mailing list