Code Search for Developers
 
 
  

find_sub.c from The Open2x Project at Krugle


Show find_sub.c syntax highlighted

/*              
 *  Original code routine from Mplayer < www.mplayerhq.hu >             
 *
 *  - godori <ghcstop>, www.aesop-embedded.org
 *    => Modified. Jan, 2005
 */

#if 0
#    ifdef USE_SUB
  
if (subdata && sh_video->pts > 0)
{
    float           pts = sh_video->pts;

    if (sub_fps == 0)
        sub_fps = sh_video->fps;
    current_module = "find_sub";
    
    if (pts > sub_last_pts || pts < sub_last_pts - 1.0)
    {
        find_sub(subdata, (pts + sub_delay) * (subdata->sub_uses_time ? 100. : sub_fps));
        
        sub_last_pts = pts;
    }
    current_module = NULL;
}
#    endif
#endif

#include "config.h"
#ifdef USE_OSD
#    include <stdio.h>
#    include "subreader.h"
#    include "mp_msg.h"
#    include "help_mp.h"

#    ifdef DEBUG
#        define dprintf(x...) printf(x)
#    else
#        define dprintf(x...)
#    endif

#    ifdef GDEBUG
extern FILE    *dbg;

#        define gprintf(x...) fprintf(dbg, x)
#    else
#        define gprintf(x...)
#    endif

static int      current_sub = 0;


static int      nosub_range_start = -1;
static int      nosub_range_end = -1;


extern float    sub_delay;
extern float    sub_fps;

extern subtitle *vo_sub;        
extern int      subtitle_changed;   

void
step_sub(sub_data * subd, float pts, int movement)
{
    subtitle       *subs;
    int             key;

    if (subd == NULL)
        return;
    subs = subd->subtitles;
    key = (pts + sub_delay) * (subd->sub_uses_time ? 100 : sub_fps);

    
#    if 0
    vo_osd_changed(OSDTYPE_SUBTITLE);
#    else
    subtitle_changed = 1;
#    endif


    if (movement > 0 && key < subs[current_sub].start)
        movement--;
    if (movement < 0 && key >= subs[current_sub].end)
        movement++;

    
    if (current_sub + movement < 0)
        movement = 0 - current_sub;
    if (current_sub + movement >= subd->sub_num)
        movement = subd->sub_num - current_sub - 1;

    current_sub += movement;
    sub_delay = subs[current_sub].start / (subd->sub_uses_time ? 100 : sub_fps) - pts;
}


inline void
find_sub(sub_data * subd, int key)
{
    subtitle       *subs;
    int             i,
                    j;

    if (!subd || subd->sub_num == 0)
        return;
    subs = subd->subtitles;

    
    if (vo_sub)                 
    {
        gprintf("ye vo_sub: ");
        if (key >= vo_sub->start && key <= vo_sub->end)
        {
            gprintf("no change\n");
            return;             
        }
    }
    else                        
    {
        
        gprintf("no vo_sub: ");
        
        if (key > nosub_range_start && key < nosub_range_end)
        {
            gprintf("no change\n");
            return;             
        }
    }

    gprintf("change\n");
    
#    if 0
    vo_osd_changed(OSDTYPE_SUBTITLE);
#    else
    subtitle_changed = 1;
#    endif
    
    if (key <= 0)
    {
        vo_sub = NULL;          
        return;
    }
    
    if (current_sub >= 0 && current_sub + 1 < subd->sub_num)
    {
        
        if (key > subs[current_sub].end && key < subs[current_sub + 1].start)
        {
            
            nosub_range_start = subs[current_sub].end;
            nosub_range_end = subs[current_sub + 1].start;
            gprintf("1 NULL set\n");    
            vo_sub = NULL;
            return;
        }
        ++current_sub;
        vo_sub = &subs[current_sub];
        gprintf("1 vo_sub[%d]->text = %s ", current_sub, vo_sub->text[0]);
        
        if (key >= vo_sub->start && key <= vo_sub->end)
        {
            gprintf("return \n");
            return;             
        }
        
        gprintf("no return \n");
    }
    
    i = 0;
    j = subd->sub_num - 1;
    
    while (j >= i)
    {
        current_sub = (i + j + 1) / 2;
        vo_sub = &subs[current_sub];
        if (key < vo_sub->start)
        {
            j = current_sub - 1;
        }
        else if (key > vo_sub->end)
        {
            i = current_sub + 1;
        }
        else
        {
            gprintf("2 vo_sub[%d]->text = %s\n", current_sub, vo_sub->text[0]);
            return;             
        }
    }
    
    if (key < vo_sub->start)
    {
        if (current_sub <= 0)
        {
            
            nosub_range_start = key - 1;    
            nosub_range_end = vo_sub->start;
            gprintf("2 NULL set: FIRST...  key=%d  end=%d  \n", key, vo_sub->start);
            vo_sub = NULL;
            return;
        }
        --current_sub;

        if (key > subs[current_sub].end && key < subs[current_sub + 1].start)
        {
            
            nosub_range_start = subs[current_sub].end;
            nosub_range_end = subs[current_sub + 1].start;
            gprintf("3 NULL set: No sub... 1 \n");
            vo_sub = NULL;
            return;
        }
        gprintf("HEH????  ");
    }
    else
    {
        if (key <= vo_sub->end)
        {
            gprintf("JAJJ!  ");
        }
        else if (current_sub + 1 >= subd->sub_num)
        {
            
            nosub_range_start = vo_sub->end;
            nosub_range_end = 0x7FFFFFFF;   
            gprintf("3 NULL set: END!?\n");
            vo_sub = NULL;
            return;
        }
        else if (key > subs[current_sub].end && key < subs[current_sub + 1].start)
        {
            
            nosub_range_start = subs[current_sub].end;
            nosub_range_end = subs[current_sub + 1].start;
            gprintf("4 NULL set: No sub... 2 \n");
            vo_sub = NULL;
            return;
        }
    }

    printf("SUB ERROR:  %d  ?  %d --- %d  [%d]  \n", key, (int) vo_sub->start, (int) vo_sub->end, current_sub);

    vo_sub = NULL;              
}

#endif




See more files for this project here

The Open2x Project

The Open2x project exists to provide an open source resource for the GP2X handheld console based on the MagicEyes MMSP2 processing platform and MP2520F SoC. The project hosts Linux kernel source for the GP2X, boot loader (U-Boot) source and more.

Project homepage: http://www.distant-earth.com/open2x
Programming language(s): Assembly,C,C++
License: other

  default_skin/
    asf.png
    avi.png
    body.png
    dat.png
    downarrow.png
    error.png
    ext.png
    ext_on.png
    folder.png
    full.png
    loading.png
    mpg.png
    nand.png
    nand_on.png
    normal.png
    resume.png
    save.png
    sd.png
    sd_on.png
    selectbar.png
    uparrow.png
    wmv.png
  etc/
    codecs.conf
    dvb-menu.conf
    example.conf
    input.conf
    inttypes.h
    menu.conf
    mplayer.desktop
    mplayer.ico
  fbdisp/
    Makefile
    fblin16.c
    fblin24.c
    fblin32.c
    fbs.h
    fontdisp.h
    fontout.c
    gfxdev.h
    gfxfontext.c
    gfxfontload.c
    gfxfontout.c
    gfxtype.h
    gulim_96_10_eng.c
    gulim_96_10_han.c
    main.c
    scr_fb.c
  help/
    help_diff.sh
    help_mp-bg.h
    help_mp-cs.h
    help_mp-de.h
    help_mp-dk.h
    help_mp-el.h
    help_mp-en.h
    help_mp-es.h
    help_mp-fr.h
    help_mp-hu.h
    help_mp-it.h
    help_mp-ja.h
    help_mp-ko.h
    help_mp-mk.h
    help_mp-nl.h
    help_mp-no.h
    help_mp-pl.h
    help_mp-pt_BR.h
    help_mp-ro.h
    help_mp-ru.h
  libaf/
  libao2/
  libmpcodecs/
  libmpdemux/
  loader/
  osdep/
  AUTHORS
  DirDisplay.c
  DirDisplay.h
  DirList.c
  DirList.h
  FontDisplay.c
  FontDisplay.h
  LICENSE
  Makefile
  bswap.h
  codec-cfg.c
  codec-cfg.h
  config.h
  config.mak
  csource.lst
  cx25874.h
  drawcontrol.c
  drawcontrol.h
  dualcpu.h
  filelistview.c
  filelistview.h
  find_sub.c
  g2player.h
  get_path.c
  glock.c
  glock.h
  guictrl.c
  guictrl.h
  gv.c
  gvlib_export.h
  help_mp.h
  i2c.h
  imgNumber.h
  imgbinary.h
  m_config.c
  m_config.h
  m_option.c
  m_option.h
  m_struct.c
  m_struct.h
  mangle.h
  mixer.c
  mixer.h
  mmsp2_940_if.c
  mmsp2_if.h
  mp_msg.c
  mp_msg.h
  mplayer.c
  mplayer.h
  open2x-mplayer.sh
  rtc_1024_table.h
  subdisp.c
  subdisp.h
  subreader.c
  subreader.h
  typed.h
  version.h
  vpp.h
  vpts_q.c
  wincetype.h