Ticket #9266: mythweb-streaming_aspect_fix.patch

File mythweb-streaming_aspect_fix.patch, 4.6 KB (added by Daniel Osborne <daniel@…>, 13 years ago)

Patch to fix aspect ratio detection in MythWeb

  • branches/release-0-24-fixes/mythplugins/mythweb/tv/classes/Program.php

     
    788788
    789789    public function getAspect() {
    790790        global $db;
    791         $aspect = $db->query_col('SELECT recordedmarkup.type
     791        $sh = $db->query('SELECT recordedmarkup.data FROM recordedmarkup WHERE recordedmarkup.chanid=? AND recordedmarkup.starttime=FROM_UNIXTIME(?) AND (recordedmarkup.type=30 OR recordedmarkup.type=31) AND recordedmarkup.data AND (recordedmarkup.mark=0 OR recordedmarkup.mark=1) IS NOT NULL ORDER BY recordedmarkup.type', $this->chanid, $this->recstartts);
     792        $x = $sh->fetch_col();           # type = 30
     793        if( $x) $y = $sh->fetch_col();   # type = 31
     794
     795        if( $x && $y && $x > 720 )
     796        {
     797            return $x/$y;
     798        }
     799        else
     800        {
     801            $aspect = $db->query_col('SELECT recordedmarkup.type
    792802                                    FROM recordedmarkup
    793803                                   WHERE recordedmarkup.chanid    = ?
    794804                                     AND recordedmarkup.starttime = FROM_UNIXTIME(?)
     
    805815                                   $this->chanid,
    806816                                   $this->recstartts
    807817                                   );
    808         switch($aspect) {
    809             case 10:
    810                 return 1;
    811             case 11:
    812                 return 4/3;
    813             case 12:
    814                 return 16/9;
    815             case 13:
    816                 return 2.21/1;
    817             case 14:
    818                 return 4/3;
    819             default:
    820                 return 4/3;
    821         }
     818            switch($aspect) {
     819                case 10:
     820                    return 1;
     821                case 11:
     822                    return 4/3;
     823                case 12:
     824                    return 16/9;
     825                case 13:
     826                    return 2.21/1;
     827                case 14:
     828                    return 4/3;
     829                default:
     830                    return 4/3;
     831            }
     832        }
    822833    }
    823834
    824835}
  • branches/release-0-24-fixes/mythplugins/mythweb/stream/stream_flv.pl

     
    5555    my ($abitrate) = $sh->fetchrow_array;
    5656    $sh->finish();
    5757# auto-detect height based on aspect ratio
    58     $sh = $dbh->prepare('SELECT data FROM recordedmarkup WHERE chanid=? AND starttime=FROM_UNIXTIME(?) AND (type=30 OR type=31) AND mark=0 AND data IS NOT NULL ORDER BY type');
     58    $sh = $dbh->prepare('SELECT data FROM recordedmarkup WHERE chanid=? AND starttime=FROM_UNIXTIME(?) AND (type=30 OR type=31)  AND (mark=0 OR mark=1) AND data IS NOT NULL ORDER BY type');
    5959    $sh->execute($chanid,$starttime);
    6060    $x = $sh->fetchrow_array;           # type = 30
    6161    $y = $sh->fetchrow_array if ($x);   # type = 31
    6262    $width = round_even($width);
    63     if ($x && $y) {
    64         $height = round_even($width * ($y/$x));
    65     } else {
    66         $height = round_even($width * 3/4);
     63
     64    if (!$x || !$y || $x <= 720) {      # <=720 means SD
     65        $sh->finish();
     66        $sh = $dbh->prepare('SELECT recordedmarkup.type
     67                                    FROM recordedmarkup
     68                                   WHERE recordedmarkup.chanid    = ?
     69                                     AND recordedmarkup.starttime = FROM_UNIXTIME(?)
     70                                     AND recordedmarkup.type      IN (10, 11, 12, 13, 14)
     71                                    GROUP BY recordedmarkup.type
     72                                ORDER BY SUM((SELECT IFNULL(rm.mark, recordedmarkup.mark)
     73                                                    FROM recordedmarkup AS rm
     74                                               WHERE rm.chanid = recordedmarkup.chanid
     75                                                     AND rm.starttime = recordedmarkup.starttime
     76                                                 AND rm.type IN (10, 11, 12, 13, 14)
     77                                                 AND rm.mark > recordedmarkup.mark
     78                                            ORDER BY rm.mark ASC LIMIT 1)- recordedmarkup.mark) DESC
     79                                   LIMIT 1'
     80                                   );
     81        $sh->execute($chanid,$starttime);
     82        $aspect = $sh->fetchrow_array;
     83
     84        if( $aspect == 10 ) {
     85            $x = $y = 1;
     86        } elsif( $aspect == 11 ) {
     87            $x = 4; $y = 3;
     88        } elsif( $aspect == 12 ) {
     89            $x = 16; $y = 9;
     90        } elsif( $aspect == 13 ) {
     91            $x = 2.21; $y = 1;
     92        } elsif( $aspect == 14 ) {
     93            $x = 4; $y = 3;
     94        } else {
     95            $x = 4; $y = 3;
     96        }
    6797    }
     98    $height = round_even($width * ($y/$x));
    6899    $sh->finish();
    69100
    70101    $width    = 320 unless ($width    && $width    > 1);