File:PAL timing visualisation 1.png
Original file (1,280 × 625 pixels, file size: 4 KB, MIME type: image/png)
Captions
Summary
[edit]DescriptionPAL timing visualisation 1.png |
English: see below |
Date | |
Source | Own work |
Author | Sloyment |
PAL timing visualisation
[edit]This is a series of five images:
Source code
[edit]- Images 1–3 have been created from a script.
- Images 2 and 3 have been rescaled to 945×625 in GIMP afterwards.
- Images 4 and 5 are edited versions of images 2 and 3.
// Author: Sloyment
// License: Creative Commons Zero
// Compile and run:
// sudo apt-get install libgd-dev
// gcc PAL.c -lgd
// ./a.out
#include <stdlib.h>
#include "gd.h"
int main () {
int timings[] = {
235, 235, 90, 230, 255, 1685, 315, 155, // 32.00 µs
235, 2495, 315, 155 // 32.00 µs
};
// 0: sync, 1: black, 2: burst, 3: picture
int lt1[][12] = { // index
{0,0,1,2,1,3,3,3, 3,3,3,1}, // 0: line with picture info
{0,0,1,2,1,1,1,1, 1,1,1,1}, // 1: line without picture info
{0,0,1,2,1,1,1,1, 3,3,3,1}, // 2: second half only (23)
{0,0,1,2,1,3,3,1, 0,1,1,1}, // 3: first half only (623)
{0,0,0,0,0,0,1,1, 0,0,1,1}, // 4: long pulses
{0,1,1,1,1,1,1,1, 0,1,1,1}, // 5: short pulses
{0,0,0,0,0,0,1,1, 0,1,1,1}, // 6: long–short (3)
{0,1,1,1,1,1,1,1, 0,0,1,1}, // 7: short–long (313)
{0,1,1,1,1,1,1,1, 1,1,1,1} // 8: one short pulse (318)
};
int lt2[] = {
-1, // numbering starts with 1
4,4,6,5,5, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,2,0,0, 0,0,0,0,0, // 1– 30
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 31– 60
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 61– 90
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 91–120
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 121–150
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 151–180
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 181–210
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 211–240
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 241–270
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 271–300
0,0,0,0,0, 0,0,0,0,0, 5,5,7,4,4, 5,5,8,1,1, 1,1,1,1,1, 1,1,1,1,1, // 301–330
1,1,1,1,1, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 331–360
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 361–390
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 391–420
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 421–450
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 451–480
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 481–510
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 511–540
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 541–570
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, // 571–600
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,3,5,5 // 601–625
};
int a,b,c,d,e;
// workaround
int * data = malloc(1280*625*4 * sizeof(int));
int * signal = data;
int * img1[625];
int * img2[625];
int * img3[625];
for (a=0;a<625;a++) {
b=a*1280; c=1280*625;
img1[a] = data + (b+c); c+=1280*625;
img2[a] = data + (b+c); c+=1280*625;
img3[a] = data + (b+c);
}
// int signal[625*1280]; // 0.05 µs per pixel
// int img1[625][1280]; // 0.05 µs per pixel
// int img2[625][1280]; // 0.05 µs per pixel
// int img3[625][1280]; // 0.05 µs per pixel
for (a=1;a<=625;a++) { // count the scan lines from 1..625
for (b=0,c=0;b<12;b++) {
d = lt1[lt2[a]][b];
e = c + (timings[b]/5);
for (;c<e;c++) {
signal[(a-1)*1280+c] = d;
} } }
for (a=1;a<=625;a++) {
for (b=0;b<1280;b++) {
d = (a-1)*1280+b;
img1[a-1][b] = signal[d];
c = (a<313)? a*2-1 : a*2-626; // deinterlace: 313, 1, 314, 2, 315 … 312, 625
img2[c][b] = signal[d];
d += (4+144+12)*1280 + 840; // add delay: 10282 µs
d %= 1280 * 625; // wrap
img3[c][b] = signal[d];
} }
{ // begin GD stuff
gdImagePtr im = gdImageCreateTrueColor(1280, 625);
int x,y;
void im_save(char filename[]){
FILE *f1;
f1 = fopen(filename, "wb");
gdImagePng(im, f1);
fclose(f1);
}
inline void px(int x, int y, int color) {
int r,g,b; // translate to actual colors:
// 0: sync, 1: black, 2: burst, 3: picture
if (color==0) { r=0; g=0; b=0; }
if (color==1) { r=64; g=64; b=64; }
if (color==2) { r=192; g=128; b=0; }
if (color==3) { r=128; g=192; b=255; }
im->tpixels[y][x]=(r<<16)|(g<<8)|b;
}
for (y=0;y<625;y++) for (x=0;x<1280;x++) px (x,y,img1[y][x]);
im_save ("PAL timing visualisation 1.png");
for (y=0;y<625;y++) for (x=0;x<1280;x++) px (x,y,img2[y][x]);
im_save ("PAL timing visualisation 2.png");
for (y=0;y<625;y++) for (x=0;x<1280;x++) px (x,y,img3[y][x]);
im_save ("PAL timing visualisation 3.png");
gdImageDestroy(im);
} // end GD stuff
free (data);
return 0;
}
Licensing
[edit]This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. | |
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 17:45, 3 January 2017 | 1,280 × 625 (4 KB) | Sloyment (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following 5 pages use this file:
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Horizontal resolution | 37.8 dpc |
---|---|
Vertical resolution | 37.8 dpc |