Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #4523 from koying/fixamcinitformat

FIX: [mediacodec] proper initialization of output format
commit 577494a1dc36209214e294c229b2bed8b137f17d 2 parents 977c2a8 + 8a15eb7
jmarshallnz jmarshallnz authored
49 xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp
@@ -438,13 +438,6 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio
438 438 }
439 439 }
440 440
441   - if (!ConfigureMediaCodec())
442   - {
443   - m_codec.reset();
444   - SAFE_DELETE(m_bitstream);
445   - return false;
446   - }
447   -
448 441 // setup a YUV420P DVDVideoPicture buffer.
449 442 // first make sure all properties are reset.
450 443 memset(&m_videobuffer, 0x00, sizeof(DVDVideoPicture));
@@ -460,6 +453,13 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio
460 453 m_videobuffer.iDisplayWidth = m_hints.width;
461 454 m_videobuffer.iDisplayHeight = m_hints.height;
462 455
  456 + if (!ConfigureMediaCodec())
  457 + {
  458 + m_codec.reset();
  459 + SAFE_DELETE(m_bitstream);
  460 + return false;
  461 + }
  462 +
463 463 CLog::Log(LOGINFO, "CDVDVideoCodecAndroidMediaCodec:: "
464 464 "Open Android MediaCodec %s", m_codecname.c_str());
465 465
@@ -773,6 +773,10 @@ bool CDVDVideoCodecAndroidMediaCodec::ConfigureMediaCodec(void)
773 773 return false;
774 774 }
775 775
  776 + // There is no guarantee we'll get an INFO_OUTPUT_FORMAT_CHANGED
  777 + // Configure the output with defaults
  778 + ConfigureOutputFormat(&mediaformat);
  779 +
776 780 return true;
777 781 }
778 782
@@ -886,7 +890,8 @@ int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void)
886 890 }
887 891 else if (index == CJNIMediaCodec::INFO_OUTPUT_FORMAT_CHANGED)
888 892 {
889   - OutputFormatChanged();
  893 + CJNIMediaFormat mediaformat = m_codec->getOutputFormat();
  894 + ConfigureOutputFormat(&mediaformat);
890 895 }
891 896 else if (index == CJNIMediaCodec::INFO_TRY_AGAIN_LATER)
892 897 {
@@ -902,19 +907,17 @@ int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void)
902 907 return rtn;
903 908 }
904 909
905   -void CDVDVideoCodecAndroidMediaCodec::OutputFormatChanged(void)
  910 +void CDVDVideoCodecAndroidMediaCodec::ConfigureOutputFormat(CJNIMediaFormat* mediaformat)
906 911 {
907   - CJNIMediaFormat mediaformat = m_codec->getOutputFormat();
908   -
909   - int width = mediaformat.getInteger("width");
910   - int height = mediaformat.getInteger("height");
911   - int stride = mediaformat.getInteger("stride");
912   - int slice_height= mediaformat.getInteger("slice-height");
913   - int color_format= mediaformat.getInteger("color-format");
914   - int crop_left = mediaformat.getInteger("crop-left");
915   - int crop_top = mediaformat.getInteger("crop-top");
916   - int crop_right = mediaformat.getInteger("crop-right");
917   - int crop_bottom = mediaformat.getInteger("crop-bottom");
  912 + int width = mediaformat->getInteger("width");
  913 + int height = mediaformat->getInteger("height");
  914 + int stride = mediaformat->getInteger("stride");
  915 + int slice_height= mediaformat->getInteger("slice-height");
  916 + int color_format= mediaformat->getInteger("color-format");
  917 + int crop_left = mediaformat->getInteger("crop-left");
  918 + int crop_top = mediaformat->getInteger("crop-top");
  919 + int crop_right = mediaformat->getInteger("crop-right");
  920 + int crop_bottom = mediaformat->getInteger("crop-bottom");
918 921
919 922 CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec:: "
920 923 "width(%d), height(%d), stride(%d), slice-height(%d), color-format(%d)",
@@ -939,7 +942,11 @@ void CDVDVideoCodecAndroidMediaCodec::OutputFormatChanged(void)
939 942 height = slice_height = m_hints.height;
940 943 }
941 944 if (stride <= width)
942   - stride = width;
  945 + stride = width;
  946 + if (!crop_right)
  947 + crop_right = width-1;
  948 + if (!crop_bottom)
  949 + crop_bottom = height-1;
943 950 if (slice_height <= height)
944 951 {
945 952 slice_height = height;
3  xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.h
@@ -32,6 +32,7 @@
32 32 class CJNISurface;
33 33 class CJNISurfaceTexture;
34 34 class CJNIMediaCodec;
  35 +class CJNIMediaFormat;
35 36 class CDVDMediaCodecOnFrameAvailable;
36 37 class CJNIByteBuffer;
37 38 class CBitstreamConverter;
@@ -106,7 +107,7 @@ class CDVDVideoCodecAndroidMediaCodec : public CDVDVideoCodec
106 107 void FlushInternal(void);
107 108 bool ConfigureMediaCodec(void);
108 109 int GetOutputPicture(void);
109   - void OutputFormatChanged(void);
  110 + void ConfigureOutputFormat(CJNIMediaFormat* mediaformat);
110 111
111 112 // surface handling functions
112 113 static void CallbackInitSurfaceTexture(void*);

0 comments on commit 577494a

Please sign in to comment.
Something went wrong with that request. Please try again.