Sunday, May 1, 2011

C & Assembly to Perform 16x16 Pixel-Block Motion Estimation

char *btpr; /* pointer to start row of 16x16 pixel block being compressed */
char *cptr; /* pointer to start row of 16x16 pixel reference block */
val = 0;
for (i=0; i<16; i++) {
for (j=0; j<16; j++) {
data = (*(bptr++)- *(cptr++));
if (data<0){val -= data;}
else {val += data;}
}
/* Fast out after this row if best match has been exceeded */
 if (val > best_value) break;
/* Update pointer to next row */
 bptr += (rm->width - 16);
/* Update pointer  to next row */
  cptr += (cm->width - 16);
}

Example 2. Inner-Core Absolute Differences for 16x16 Pixel Block
__asm {
   movdqu xmm0, [m1]
   movdqu xmm1, [m2]
   movdqa xmm2, xmm0
   psubusb xmm0, xmm1
   psubusb xmm1, xmm2
   por xmm0, xmm1
   movdqa xmm1, xmm0
   punpcklbw xmm0, xmm6
   punpcklbw xmm1, xmm6
   movdqa xmm3, xmm1
   pshufd xmm1, xmm0, 238
   pshufd xmm3, xmm0, 68
 paddw xmm1, xmm3
movdqa xmm4, xmm1
pshufd xmm4, xmm4, 78
   paddw xmm1, xmm4

}

Monday, April 11, 2011

Scene Change Detection

Simple Scene Detection Using YDifference

Code:
#Script to find scene changes

filename = "e:\scenes.txt"
global blankthreshold=2.0
source = AVISource("e:\fs.avi").convertTOYV12().killaudio()

#Comment out the following lines after blankthreshold has been determined
script = """Subtitle("\nNext/Prev = " + String( YDifferenceToNext(last) \
                    / YDifferenceFromPrevious(last) ), lsp=0)"""
final = ScriptClip(source,script)
return final

#Uncomment the following two lines when doing the actual scene detection
#WriteFileIf(source, filename, "(YDifferenceToNext(last) / \
#           YDifferenceFromPrevious(last)>blankthreshold)", "current_frame+1", append = false)
Scene Detection Using MVTools2
Code:
#Script to find scene changes

Loadplugin("C:\Program Files\AviSynth 2.5\plugins\MVTools\mvtools2.dll")

filename = "e:\scenes.txt"
BlockChangeThresh  = 350 # Default: 350. Increase to reduce number of scenes detected;
                         # Determines whether a block has changed from prev frame.
Num_blocks_changed =  90 # Default: 90. Increase to reduce number of scenes detected;
                         # How many changed blocks (given threshhold) must change to trigger scene change

source=AVISource("e:\fs.avi").killaudio().colorYUV(autogain=true) #add this to increase contrast
source_fields=source.separatefields().selecteven().convertTOYV12(interlaced=false)
source_super = source_fields.MSuper(pel=2, sharp=0)

backward_vec = MAnalyse(source_super,isb = true, delta = 1, blksize=16,search=0)

SceneChange = MSCDetection (source_fields, backward_vec,thSCD1=BlockChangeThresh,thSCD2=Num_blocks_changed)

#Uncomment following line for troubleshooting. It puts the scene change threshold numbers on the screen.
ScriptClip(source_fields,"Subtitle(String(AverageLuma(SceneChange ) ),align=5)")

#This line writes frame numbers to file. These can be imported into Vegas or other editor
#WriteFileIf(source_fields,filename, "(AverageLuma(SceneChange)>30)" , "current_frame+1", flush=false)
Scene Detection Using Depanestimate
Code:
#Script to find scene changes
loadPlugin("c:\Program Files\AviSynth 2.5\plugins\depanestimate.dll")
loadPlugin("c:\Program Files\AviSynth 2.5\plugins\depan.dll")

filename = "e:\scenes.txt"

AVISource("e:\fs.avi").convertTOYV12(interlaced=true).killaudio()
separatefields().selecteven().convertTOYV12(interlaced=false)

#The "trust" parameter is what determines the scene change threshold.
#Lower number results in fewer scenes.
data=DepanScenes( DepanEstimate(trust=2) )

#Uncomment following line to help determine "trust" value.
ScriptClip("Subtitle(String(AverageLuma(data ) ),align=5)")

#WriteFileIf(filename, "(AverageLuma(data)>30)" , "current_frame", flush=false)
Scene Detection Using Remove Dirt
Code:
#Script to find scene changes
filename = "e:\scenes.txt"
Scene_Thresh = 2.0  #Higher number = more scenes

AVISource("e:\fs.avi").ConvertToYV12()

Begin = Blackness(last)
End=Subtitle("END OF SCENE", align=1,size=30)
Motion=Subtitle("GLOBAL MOTION",align=5,size=30)

#ScriptClip("Subtitle(String(SCSelect(Last,BlackFrame) ),align=5)")
scene_change = SCSelect(Last,Begin,End,Motion,Dfactor=Scene_Thresh )

#Remove comment to see scene change numbers
ScriptClip("Subtitle(String(AverageLuma(scene_change ) ),align=5)")

#Uncomment next line to actually create scene change numbers
#WriteFileIf(filename, "AverageLuma(scene_change )<17" , "current_frame", flush=false)

Sunday, March 13, 2011

HTTP Live Streaming Brief

HTTP Live Streaming Overview



·         Streaming audio or video to iPhone, iPod touch, iPad
·         Streaming live events without special server software
·         Sending video on demand with encryption and authentication
you should learn about HTTP Live Streaming.
HTTP Live Streaming lets you send audio and video over HTTP from an ordinary web server for playback on iOS-based devices—including iPhone, iPad, iPod touch, and Apple TV—and on desktop computers (Mac OS X). HTTP Live Streaming supports both live broadcasts and prerecorded content (video on demand). HTTP Live streaming supports multiple alternate streams at different bit rates, and the client software can switch streams intelligently as network bandwidth changes. HTTP Live streaming also provides for media encryption and user authentication over HTTPS, allowing publishers to protect their work.
All devices running iOS 3.0 and later include built-in client software for HTTP Live Streaming. The Safari browser can play HTTP streams within a webpage on iPad and desktop computers, and Safari launches a full-screen media player for HTTP streams on iOS devices with small screens, such as iPhone and iPod touch. Apple TV 2 and later includes an HTTP Live Streaming client.

Safari plays HTTP Live streams natively as the source for the <video> tag. Mac OS X developers can use the QTKit and AVFoundation frameworks to create desktop applications that play HTTP Live Streams, and iOS developers can use the MediaPlayer and AVFoundation frameworks to create iOS apps.


Because it uses HTTP, this kind of streaming is automatically supported by nearly all edge servers, media distributors, caching systems, routers, and firewalls.


The HTTP Live Streaming specification is an IETF Internet-Draft. For a link to the specification, see the See Also section below.

At a Glance

HTTP Live Streaming is a way to send audio and video over HTTP from a web server to client software on the desktop or to iOS-based devices.





You Can Send Audio and Video Without Special Server Software

You can serve HTTP Live Streaming audio and video from an ordinary web server. The client software can be the Safari browser or an app that you’ve written for iOS or Mac OS X.
HTTP Live Streaming sends audio and video as a series of small files, typically of about 10 seconds duration, called media segment files. An index file, or playlist, gives the clients the URLs of the media segment files. The playlist can be periodically refreshed to accommodate live broadcasts, where media segment files are constantly being produced. You can embed a link to the playlist in a webpage or send it to an app t

Thursday, March 10, 2011

Unix/Linux Command Line Cheat Sheet

All Linux Commands with Example


Table of Contents