Skip to content

Commit

Permalink
Add orientation support for videos
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed Oct 3, 2013
1 parent 3e8d718 commit f944de7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions OMXReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,9 @@ bool OMXReader::GetHints(AVStream *stream, COMXStreamInfo *hints)
hints->aspect = 0.0f;
if (m_bAVI && stream->codec->codec_id == CODEC_ID_H264)
hints->ptsinvalid = true;
AVDictionaryEntry *rtag = m_dllAvUtil.av_dict_get(stream->metadata, "rotate", NULL, 0);
if (rtag)
hints->orientation = atoi(rtag->value);
}

return true;
Expand Down
1 change: 1 addition & 0 deletions OMXStreamInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class COMXStreamInfo
int level; // encoder level of the stream reported by the decoder. used to qualify hw decoders.
int profile; // encoder profile of the stream reported by the decoder. used to qualify hw decoders.
bool ptsinvalid; // pts cannot be trusted (avi's).
int orientation; // video orientation in clockwise degrees

// AUDIO
int channels;
Expand Down
2 changes: 1 addition & 1 deletion OMXVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ bool COMXVideo::Open(COMXStreamInfo &hints, OMXClock *clock, const CRect &DestRe
m_setStartTime = true;
m_setStartTimeText = true;

switch(0)
switch(hints.orientation)
{
case 90:
m_transform = OMX_DISPLAY_ROT90;
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Using OMXPlayer
--audio_queue n Size of audio input queue in MB
--video_queue n Size of video input queue in MB
--threshold n Amount of buffered data required to come out of buffering in seconds
--orientation n Set orientation of video (0, 90, 180 or 270)
--key-config <file> Uses key bindings specified in <file> instead of the default

For example:
Expand Down
9 changes: 9 additions & 0 deletions omxplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ void print_usage()
printf(" --audio_queue n Size of audio input queue in MB\n");
printf(" --video_queue n Size of video input queue in MB\n");
printf(" --threshold n Amount of buffered data required to come out of buffering in seconds\n");
printf(" --orientation n Set orientation of video (0, 90, 180 or 270)\n");
printf(" --key-config <file> Uses key bindings specified in <file> instead of the default\n");
}

Expand Down Expand Up @@ -542,6 +543,7 @@ int main(int argc, char *argv[])
float audio_queue_size = 0.0;
float video_queue_size = 0.0;
float m_threshold = 0.2f; // amount of audio/video required to come out of buffering
int m_orientation = -1; // unset
TV_DISPLAY_STATE_T tv_state;

const int font_opt = 0x100;
Expand All @@ -563,6 +565,7 @@ int main(int argc, char *argv[])
const int key_config_opt = 0x10d;
const int amp_opt = 0x10e;
const int no_osd_opt = 0x202;
const int orientation_opt = 0x204;

struct option longopts[] = {
{ "info", no_argument, NULL, 'i' },
Expand Down Expand Up @@ -602,6 +605,7 @@ int main(int argc, char *argv[])
{ "boost-on-downmix", no_argument, NULL, boost_on_downmix_opt },
{ "key-config", required_argument, NULL, key_config_opt },
{ "no-osd", no_argument, NULL, no_osd_opt },
{ "orientation", required_argument, NULL, orientation_opt },
{ 0, 0, 0, 0 }
};

Expand Down Expand Up @@ -744,6 +748,9 @@ int main(int argc, char *argv[])
case threshold_opt:
m_threshold = atof(optarg);
break;
case orientation_opt:
m_orientation = atoi(optarg);
break;
case 'b':
m_blank_background = true;
break;
Expand Down Expand Up @@ -925,6 +932,8 @@ int main(int argc, char *argv[])
m_omx_reader.SeekTime(m_seek_pos * 1000.0f, false, &startpts); // from seconds to DVD_TIME_BASE
}

if (m_orientation >= 0)
m_hints_video.orientation = m_orientation;
if(m_has_video && !m_player_video.Open(m_hints_video, m_av_clock, DestRect, m_Deinterlace ? VS_DEINTERLACEMODE_FORCE:m_NoDeinterlace ? VS_DEINTERLACEMODE_OFF:VS_DEINTERLACEMODE_AUTO,
m_hdmi_clock_sync, m_thread_player, m_display_aspect, video_queue_size, video_fifo_size))
goto do_exit;
Expand Down

2 comments on commit f944de7

@fcarlier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fcarlier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMXClock.cpp:547:16: warning: 'int64_t CurrentHostFrequency()' defined but not used [-Wunused-function]

Please sign in to comment.