https://bitbucket.org/OtherOnePercent/tragic-lantern-2.0
Raw File
Tip revision: 6d618b53fb87c01ffd07203a5050d3894aa03627 authored by 1p on 04 June 2013, 14:06 UTC
ML Testing
Tip revision: 6d618b5
video_hacks2.c

/** \file
 * Bitrate 1100D/600D for now.
 */
#include "dryos.h"
#include "bmp.h"
#include "tasks.h"
#include "debug.h"
#include "menu.h"
#include "property.h"
#include "config.h"
#include "gui.h"
#include "lens.h"
#include "mvr.h"


#if defined(FEATURE_VIDEO_HACKS)
PROP_INT(PROP_MOVIE_SOUND_RECORD, sound);

int video_mode[5];
PROP_HANDLER(PROP_VIDEO_MODE)
{
	memcpy(video_mode, buf, 20);
}
int hacked=0;

#include "cache_hacks.h"

static CONFIG_INT( "h264.cache_hacks", bitrate_cache_hacks, 0 );
static CONFIG_INT( "h264.flushing_rate", bitrate_flushing_rate, 4 );
static CONFIG_INT( "h264.gop_size", bitrate_gop_size, 12 );
static CONFIG_INT( "h264.file_size", bitrate_file_size, 1 );


//~ uint32_t bitrate_cache_hacks = 0;
//~ uint32_t bitrate_flushing_rate = 4;
//~ uint32_t bitrate_gop_size = 12;
void patch_all()
{
#ifdef CONFIG_600D
#define UNK_GOP_LOC 0xFF25516C
#define GOP_MISMATCH_LOC 0xFF048054
#elif defined CONFIG_1100D
#define UNK_GOP_LOC 0xFF2478E8
#define GOP_MISMATCH_LOC 0xFF047E4C
#endif

cache_fake(UNK_GOP_LOC , 0xE1A00000, TYPE_ICACHE);

// Movie "Gop Mismatch"

cache_fake(GOP_MISMATCH_LOC , 0xE1A00000, TYPE_ICACHE);

//~ #ifdef CONFIG_600D //Overrun
//~ cache_fake(0xFF04C6A4 , 0xE1500000, TYPE_ICACHE);
//~ cache_fake(0xFF04C69C , 0xE1500000, TYPE_ICACHE);
//~ #endif
hacked = 1;
}
static MENU_UPDATE_FUNC(bitrate_flushing_rate_update)
{
    MENU_SET_VALUE("%d frames", bitrate_flushing_rate );

    if(!bitrate_cache_hacks)
    {
        MENU_SET_WARNING(MENU_WARN_ADVICE, "Video hacks disabled.");
    }
    if (bitrate_flushing_rate == 1)
		MENU_SET_VALUE("OFF");

}

static MENU_UPDATE_FUNC(bitrate_gop_size_update)
{
    MENU_SET_VALUE("%d frames", bitrate_gop_size);

    if(!bitrate_cache_hacks)
    {
        MENU_SET_WARNING(MENU_WARN_ADVICE, "Video hacks disabled.");
    }
    if (bitrate_gop_size == 0)
		MENU_SET_VALUE("OFF");
}

static void
video_hack_task( void* unused )
{
    uint32_t old_bitrate_cache_hacks = 0;
    uint32_t old_bitrate_gop_size = 0;
    uint32_t old_bitrate_flushing_rate = 0;

    TASK_LOOP
    {
        {
            /* anything changed? */
            if(bitrate_cache_hacks != old_bitrate_cache_hacks || bitrate_flushing_rate != old_bitrate_flushing_rate || bitrate_gop_size != old_bitrate_gop_size)
            {
                if(bitrate_cache_hacks)
                {   if (hacked != 1) patch_all();
      
                    /* patch flushing rate */
	#if defined(CACHE_HACK_FLUSH_RATE_SLAVE)
		if (bitrate_flushing_rate!=1) 
		cache_fake(CACHE_HACK_FLUSH_RATE_SLAVE, 0xE3A00000 | (bitrate_flushing_rate & 0xFF), TYPE_ICACHE);
	#endif
                    /* set GOP size */
					if (bitrate_gop_size != 0)
					{	video_mode[3] = bitrate_gop_size; //Gop Length
						prop_request_change(PROP_VIDEO_MODE, video_mode, 20);
					}
//~ #if 0
					if (sound != 1)
                    { 	int mode  = 1;
						prop_request_change(PROP_MOVIE_SOUND_RECORD, &mode, 4);
						NotifyBox(2000,"Canon sound disabled");
					}
//~ #endif
					if (bitrate_file_size == 2)
                    { 	//uint32_t* fsize = (uint32_t*) (0x1E44) + 0x50;
						uint32_t* fsize2 = (uint32_t*) (MEM(0x1E44) + 0x144);
						*fsize2 = 0x00000003;
					}

		          }
                else
                {
                    /* undo flushing rate */
	#if defined(CACHE_HACK_FLUSH_RATE_SLAVE)
          if (bitrate_flushing_rate == 1)
          cache_fake(CACHE_HACK_FLUSH_RATE_SLAVE, MEM(CACHE_HACK_FLUSH_RATE_SLAVE), TYPE_ICACHE);
	#endif
                    /* undo GOP size */
                    if (bitrate_gop_size == 0)
                    {   
					video_mode[3] = video_mode[2]/2; // FPS/2
					prop_request_change(PROP_VIDEO_MODE, video_mode, 20);
					}
                }
					if (bitrate_file_size == 1)
                    { 	//uint32_t* fsize = (uint32_t*) (0x) + 0x50;
						uint32_t* fsize2 = (uint32_t*) (MEM(0x1E44) + 0x144);
						*fsize2 = 0x00000000;
					}
                old_bitrate_cache_hacks = bitrate_cache_hacks;
                old_bitrate_gop_size = bitrate_gop_size;
                old_bitrate_flushing_rate = bitrate_flushing_rate;
            }
        }

        msleep(250);
    }
}

static struct menu_entry video_hack_menus[] = {
    {
        .name = "Video Hacks",
        .priv = &bitrate_cache_hacks,
        .max  = 1,
        .help = "Experimental hacks: flush rate, GOP size. Be careful!",
        .depends_on = DEP_MOVIE_MODE,
        .children =  (struct menu_entry[]) {
            {
                .name = "Flush rate",
                .priv = &bitrate_flushing_rate,
                .update = bitrate_flushing_rate_update,
                .min  = 1,
                .max  = 50,
                .help = "Flush movie buffer every n frames."
            },
            {
                .name = "GOP size",
                .priv = &bitrate_gop_size,
                .update = bitrate_gop_size_update,
                .min  = 0,
                .max  = 100,
                .help = "Set GOP size to n frames."
            },
            {
                .name = "File size",
                .priv = &bitrate_file_size,
                .min  = 1,
                .max  = 2,
                .choices = (const char *[]) {"4GB", "16GB"}, 
                .help = "Max File Size. Will need EOSMovieFixer.exe"
            },
            MENU_EOL
        },
    },
};

void video_hack_init()
{
    cache_lock();
    menu_add( "Movie", video_hack_menus, COUNT(video_hack_menus) );
}

INIT_FUNC(__FILE__, video_hack_init);
TASK_CREATE("video_hack_task", video_hack_task, 0, 0x1d, 0x1000 );

#endif
back to top