Skip to content

Commit

Permalink
update notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
happycube committed Nov 24, 2018
1 parent 906e3c5 commit 7ed6637
Showing 1 changed file with 63 additions and 49 deletions.
112 changes: 63 additions & 49 deletions devbook_fields.ipynb
Expand Up @@ -2,9 +2,18 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 83,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
Expand Down Expand Up @@ -69,7 +78,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 84,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -95,7 +104,7 @@
},
{
"cell_type": "code",
"execution_count": 75,
"execution_count": 95,
"metadata": {},
"outputs": [
{
Expand All @@ -113,38 +122,6 @@
"lc 15 0x8dc01e\n",
"lc 16 0x8a5ddd\n",
"lc 17 0x8a5ddd\n",
"False None\n",
"lc 15 0x8dc01e\n",
"lc 16 0x8a5ddd\n",
"lc 17 0x8a5ddd\n",
"False None\n",
"lc 15 0x8dc01e\n",
"lc 16 0xf98204\n",
"lc 17 0xf98204\n",
"True 18204\n",
"lc 15 0x8dc01e\n",
"lc 16 0x8a5ddd\n",
"lc 17 0x8a5ddd\n",
"False None\n",
"lc 15 0x8dc01e\n",
"lc 16 0xf98205\n",
"lc 17 0xf98205\n",
"True 18205\n",
"lc 15 0x8dc01e\n",
"lc 16 0x8a5ddd\n",
"lc 17 0x8a5ddd\n",
"False None\n",
"lc 15 0x8dc01e\n",
"lc 16 0x8a5ddd\n",
"lc 17 0x8a5ddd\n",
"False None\n",
"lc 15 0x8dc01e\n",
"lc 16 0xf98206\n",
"lc 17 0xf98206\n",
"True 18206\n",
"lc 15 0x8dc01e\n",
"lc 16 0x8a5ddd\n",
"lc 17 0x8a5ddd\n",
"False None\n"
]
}
Expand All @@ -162,8 +139,10 @@
" self.outfile_json = open(fname_out + '.json', 'wb')\n",
" self.outfile_audio = open(fname_out + '.pcm', 'wb') if analog_audio else None\n",
" \n",
" self.frameoutput = frameoutput\n",
" self.analog_audio = analog_audio\n",
" self.frameoutput = frameoutput\n",
" self.firstfield = None # In frame output mode, the first field goes here\n",
"\n",
" \n",
" if system == 'PAL':\n",
" self.rf = RFDecode(system = 'PAL', decode_analog_audio=analog_audio)\n",
Expand All @@ -187,7 +166,7 @@
" self.fdoffset = 0\n",
" self.audio_offset = 0\n",
" self.mtf_level = 1\n",
"\n",
" \n",
" def roughseek(self, fieldnr):\n",
" self.fdoffset = fieldnr * self.bytes_per_field\n",
" \n",
Expand Down Expand Up @@ -248,7 +227,10 @@
" else:\n",
" # redo field\n",
" self.fdoffset -= offset\n",
" \n",
" \n",
" if f is not None:\n",
" self.processfield(f)\n",
" \n",
" return f\n",
" \n",
" def processfield(self, f):\n",
Expand All @@ -259,31 +241,60 @@
" \n",
" if self.frameoutput == False:\n",
" self.outfile_video.write(picture)\n",
" else:\n",
" if self.firstfield is not None:\n",
" self.writeframe(self.firstfield, picture)\n",
" elif f.isFirstField:\n",
" self.firstfield = picture\n",
" \n",
" def writeframe(self, f1, f2):\n",
" linecount = self.rf.SysParams['frame_lines']\n",
" combined = np.zeros((self.outwidth * linecount), dtype=np.uint16)\n",
" \n",
" for i in range(0, linecount-1, 2):\n",
" curline = (i // 2) + 0\n",
" combined[((i + 0) * self.outwidth):((i + 1) * self.outwidth)] = f1[curline * self.outwidth: ((curline + 1) * self.outwidth)]\n",
" combined[((i + 1) * self.outwidth):((i + 2) * self.outwidth)] = f1[curline * self.outwidth: ((curline + 1) * self.outwidth)]\n",
"\n",
" # need to copy in the last line here, i think it's different ntsc/pal\n",
" self.outfile_video.write(combined)\n",
" \n",
"fname = '/home/cpage/vbitest/Fantasia_CAV_NTSC_side3_18200-18300_2018-11-06_09-21-07.lds'\n",
"\n",
"ldd = LDdecode(fname, 'test', load_packed_data_4_40)\n",
"ldd = LDdecode(fname, 'test', load_packed_data_4_40, frameoutput=True)\n",
"ldd.roughseek(4)\n",
"\n",
"#ldd.fdoffset = 0\n",
"fields = []\n",
"\n",
"for i in range(0, 10):\n",
" fields.append(ldd.readfield())\n"
"for i in range(0, 2):\n",
" fields.append(ldd.readfield())\n",
" ldd.processfield(fields[-1])\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 76,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ldd.processfield(fields[0])"
"ldd."
]
},
{
"cell_type": "code",
"execution_count": 69,
"execution_count": 94,
"metadata": {},
"outputs": [],
"source": [
"ldd.processfield(fields[0])\n",
"ldd.processfield(fields[1])"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -292,7 +303,7 @@
},
{
"cell_type": "code",
"execution_count": 71,
"execution_count": 78,
"metadata": {},
"outputs": [
{
Expand All @@ -301,7 +312,7 @@
"array([1711, 1299, 1706, ..., -72, -207, -254], dtype=int16)"
]
},
"execution_count": 71,
"execution_count": 78,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -312,10 +323,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 87,
"metadata": {},
"outputs": [],
"source": []
"source": [
"ldd.outfile_audio.close()\n",
"ldd.outfile_video.close()"
]
},
{
"cell_type": "code",
Expand Down

0 comments on commit 7ed6637

Please sign in to comment.