Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(570531)

Delta Between Two Patch Sets: examples/analyzer.cc

Issue 815: Render analyzer frame using cairo
Left Patch Set: Render analyzer frame using cairo Created 4 years, 7 months ago
Right Patch Set: Render analyzer frame using cairo Created 4 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « configure.ac ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /*Daala video codec 1 /*Daala video codec
2 Copyright (c) 2002-2015 Daala project contributors. All rights reserved. 2 Copyright (c) 2002-2015 Daala project contributors. All rights reserved.
3 3
4 Redistribution and use in source and binary forms, with or without 4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met: 5 modification, are permitted provided that the following conditions are met:
6 6
7 - Redistributions of source code must retain the above copyright notice, this 7 - Redistributions of source code must retain the above copyright notice, this
8 list of conditions and the following disclaimer. 8 list of conditions and the following disclaimer.
9 9
10 - Redistributions in binary form must reproduce the above copyright notice, 10 - Redistributions in binary form must reproduce the above copyright notice,
(...skipping 14 matching lines...) Expand all
25 #ifdef HAVE_CONFIG_H 25 #ifdef HAVE_CONFIG_H
26 # include "config.h" 26 # include "config.h"
27 #endif 27 #endif
28 28
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <string.h> 30 #include <string.h>
31 #include <wx/wx.h> 31 #include <wx/wx.h>
32 #include <wx/dcbuffer.h> 32 #include <wx/dcbuffer.h>
33 #include <cairo.h> 33 #include <cairo.h>
34 34
35 #include <ogg/ogg.h>
36
35 #include "daala/codec.h" 37 #include "daala/codec.h"
36 #include "daala/daaladec.h" 38 #include "daala/daaladec.h"
37 39
38 /*Smallest blocks are 4x4*/ 40 /*Smallest blocks are 4x4*/
39 # define OD_LOG_BSIZE0 (2) 41 # define OD_LOG_BSIZE0 (2)
40 /*There are 4 block sizes total (4x4, 8x8, 16x16, 32x32).*/ 42 /*There are 4 block sizes total (4x4, 8x8, 16x16, 32x32).*/
41 # define OD_NBSIZES (4) 43 # define OD_NBSIZES (4)
42 /*The maximum length of the side of a block.*/ 44 /*The maximum length of the side of a block.*/
43 # define OD_BSIZE_MAX (1 << OD_LOG_BSIZE0 + OD_NBSIZES - 1) 45 # define OD_BSIZE_MAX (1 << OD_LOG_BSIZE0 + OD_NBSIZES - 1)
44 46
45 # define OD_MAXI(a, b) ((a) ^ (((a) ^ (b)) & -((b) > (a)))) 47 # define OD_MAXI(a, b) ((a) ^ (((a) ^ (b)) & -((b) > (a))))
46 # define OD_MINI(a, b) ((a) ^ (((b) ^ (a)) & -((b) < (a)))) 48 # define OD_MINI(a, b) ((a) ^ (((b) ^ (a)) & -((b) < (a))))
47 # define OD_CLAMPI(a, b, c) (OD_MAXI(a, OD_MINI(b, c))) 49 # define OD_CLAMPI(a, b, c) (OD_MAXI(a, OD_MINI(b, c)))
48 50
49 # define OD_SIGNMASK(a) (-((a) < 0)) 51 # define OD_SIGNMASK(a) (-((a) < 0))
50 # define OD_FLIPSIGNI(a, b) (((a) + OD_SIGNMASK(b)) ^ OD_SIGNMASK(b)) 52 # define OD_FLIPSIGNI(a, b) (((a) + OD_SIGNMASK(b)) ^ OD_SIGNMASK(b))
51 # define OD_DIV_ROUND(x, y) (((x) + OD_FLIPSIGNI((y) >> 1, x))/(y)) 53 # define OD_DIV_ROUND(x, y) (((x) + OD_FLIPSIGNI((y) >> 1, x))/(y))
52 54
53 # define OD_BLOCK_SIZE4x4(bsize, bstride, bx, by) \ 55 # define OD_BLOCK_SIZE4x4(bsize, bstride, bx, by) \
54 ((bsize)[((by) >> 1)*(bstride) + ((bx) >> 1)]) 56 ((bsize)[((by) >> 1)*(bstride) + ((bx) >> 1)])
55 57
56 od_img* img_clone(od_img* input) { 58 od_img* img_clone(od_img* input) {
57 od_img *img; 59 od_img *img;
58 od_img_plane *iplane; 60 od_img_plane *iplane;
59 od_img_plane *inputplane; 61 od_img_plane *inputplane;
60 int pli; 62 int pli;
61 img = (od_img *)malloc(sizeof(*img)); 63 img = (od_img *)malloc(sizeof(*img));
62 img->nplanes = input->nplanes; 64 img->nplanes = input->nplanes;
63 img->width = input->width; 65 img->width = input->width;
64 img->height = input->height; 66 img->height = input->height;
65 for (pli = 0; pli < img->nplanes; pli++) { 67 for (pli = 0; pli < img->nplanes; pli++) {
66 iplane = img->planes + pli; 68 iplane = img->planes + pli;
67 inputplane = input->planes + pli; 69 inputplane = input->planes + pli;
68 iplane->data = (unsigned char *)malloc(inputplane->ystride*img->height); 70 iplane->data = (unsigned char *)malloc(inputplane->ystride*img->height);
tmatth 2015/07/28 16:09:26 to be consistent, should be inputplane->ystride*im
69 iplane->xdec = inputplane->xdec; 71 iplane->xdec = inputplane->xdec;
70 iplane->ydec = inputplane->ydec; 72 iplane->ydec = inputplane->ydec;
71 iplane->xstride = inputplane->xstride; 73 iplane->xstride = inputplane->xstride;
72 iplane->ystride = inputplane->ystride; 74 iplane->ystride = inputplane->ystride;
73 memcpy(iplane->data, inputplane->data, inputplane->ystride*img->height); 75 memcpy(iplane->data, inputplane->data, inputplane->ystride*img->height);
tmatth 2015/07/28 16:09:26 to be consistent, should be inputplane->ystride*im
74 } 76 }
75 return img; 77 return img;
76 } 78 }
77 79
78 class DaalaDecoder { 80 class DaalaDecoder {
79 private: 81 private:
80 FILE *input; 82 FILE *input;
81 const char *path; 83 wxString path;
82 84
83 ogg_page page; 85 ogg_page page;
84 ogg_sync_state oy; 86 ogg_sync_state oy;
85 ogg_stream_state os; 87 ogg_stream_state os;
86 88
87 daala_info di; 89 daala_info di;
88 daala_comment dc; 90 daala_comment dc;
89 daala_setup_info *dsi; 91 daala_setup_info *dsi;
90 daala_dec_ctx *dctx; 92 daala_dec_ctx *dctx;
91 93
92 bool readPage(); 94 bool readPage();
93 bool readPacket(ogg_packet *packet); 95 bool readPacket(ogg_packet *packet);
94 bool readHeaders(); 96 bool readHeaders();
95 public: 97 public:
96 od_img img; 98 od_img img;
97 int frame; 99 int frame;
98 100
99 DaalaDecoder(); 101 DaalaDecoder();
100 ~DaalaDecoder(); 102 ~DaalaDecoder();
101 103
102 bool open(const char *path); 104 bool open(const wxString &path);
105 void close();
103 bool step(); 106 bool step();
104 void reset(); 107 void restart();
105 108
106 int getWidth() const; 109 int getWidth() const;
107 int getHeight() const; 110 int getHeight() const;
108 111
109 int getFrameWidth() const; 112 int getFrameWidth() const;
110 int getFrameHeight() const; 113 int getFrameHeight() const;
111 int getRunningFrameCount() const; 114 int getRunningFrameCount() const;
112 115
113 bool setBlockSizeBuffer(unsigned char *buf, size_t buf_sz); 116 bool setBlockSizeBuffer(unsigned char *buf, size_t buf_sz);
114 bool setBandFlagsBuffer(unsigned int *buf, size_t buf_sz); 117 bool setBandFlagsBuffer(unsigned int *buf, size_t buf_sz);
118 bool setAccountingEnabled(bool enable);
119 bool getAccountingStruct(od_accounting **acct);
120 bool setDeringFlagsBuffer(unsigned char *buf, size_t buf_sz);
115 }; 121 };
122
123 static void ogg_to_daala_packet(daala_packet *dp, ogg_packet *op) {
124 dp->packet = op->packet;
125 dp->bytes = op->bytes;
126
127 dp->b_o_s = op->b_o_s;
128 dp->e_o_s = op->e_o_s;
129
130 dp->granulepos = op->granulepos;
131 dp->packetno = op->packetno;
132 }
116 133
117 bool DaalaDecoder::readPage() { 134 bool DaalaDecoder::readPage() {
118 while (ogg_sync_pageout(&oy, &page) != 1) { 135 while (ogg_sync_pageout(&oy, &page) != 1) {
119 char *buffer = ogg_sync_buffer(&oy, 4096); 136 char *buffer = ogg_sync_buffer(&oy, 4096);
120 if (buffer == NULL) { 137 if (buffer == NULL) {
121 return false; 138 return false;
122 } 139 }
123 int bytes = fread(buffer, 1, 4096, input); 140 int bytes = fread(buffer, 1, 4096, input);
124 // End of file 141 // End of file
125 if (bytes == 0) { 142 if (bytes == 0) {
(...skipping 23 matching lines...) Expand all
149 while (!done && readPage()) { 166 while (!done && readPage()) {
150 int serial = ogg_page_serialno(&page); 167 int serial = ogg_page_serialno(&page);
151 if (ogg_page_bos(&page)) { 168 if (ogg_page_bos(&page)) {
152 if (ogg_stream_init(&os, serial) != 0) { 169 if (ogg_stream_init(&os, serial) != 0) {
153 return false; 170 return false;
154 } 171 }
155 } 172 }
156 if (ogg_stream_pagein(&os, &page) != 0) { 173 if (ogg_stream_pagein(&os, &page) != 0) {
157 return false; 174 return false;
158 } 175 }
159 ogg_packet packet; 176 ogg_packet op;
160 while (!done && readPacket(&packet) != 0) { 177 while (!done && readPacket(&op) != 0) {
161 int ret = daala_decode_header_in(&di, &dc, &dsi, &packet); 178 daala_packet dp;
179 ogg_to_daala_packet(&dp, &op);
180 int ret = daala_decode_header_in(&di, &dc, &dsi, &dp);
162 if (ret < 0) { 181 if (ret < 0) {
163 if (memcmp(packet.packet, "fishead", packet.bytes)) { 182 if (memcmp(dp.packet, "fishead", dp.bytes)) {
164 fprintf(stderr, "Ogg Skeleton streams not supported\n"); 183 fprintf(stderr, "Ogg Skeleton streams not supported\n");
165 } 184 }
166 return false; 185 return false;
167 } 186 }
168 if (ret == 0) { 187 if (ret == 0) {
169 done = true; 188 done = true;
170 dctx = daala_decode_alloc(&di, dsi); 189 dctx = daala_decode_create(&di, dsi);
171 if (dctx == NULL) { 190 if (dctx == NULL) {
172 return false; 191 return false;
173 } 192 }
174 } 193 }
175 } 194 }
176 } 195 }
177 return done; 196 return done;
178 } 197 }
179 198
180 DaalaDecoder::DaalaDecoder() : input(NULL), dsi(NULL), dctx(NULL) { 199 DaalaDecoder::DaalaDecoder() : input(NULL), dsi(NULL), dctx(NULL) {
181 daala_info_init(&di); 200 daala_info_init(&di);
182 daala_comment_init(&dc); 201 daala_comment_init(&dc);
183 } 202 }
184 203
185 DaalaDecoder::~DaalaDecoder() { 204 DaalaDecoder::~DaalaDecoder() {
186 daala_info_clear(&di); 205 close();
187 daala_comment_clear(&dc); 206 }
188 ogg_sync_clear(&oy); 207
189 daala_setup_free(dsi); 208 bool DaalaDecoder::open(const wxString &path) {
190 daala_decode_free(dctx);
191 }
192
193 bool DaalaDecoder::open(const char *path) {
194 if (path == NULL) {
195 return false;
196 }
197 ogg_sync_init(&oy); 209 ogg_sync_init(&oy);
198 input = fopen(path,"rb"); 210 input = fopen(path.mb_str(), "rb");
199 if (input == NULL) { 211 if (input == NULL) {
200 return false; 212 return false;
201 } 213 }
202 this->path = path; 214 this->path = path;
203 frame = 0; 215 frame = 0;
204 return readHeaders(); 216 return readHeaders();
205 } 217 }
206 218
219 void DaalaDecoder::close() {
220 if (input) {
221 fclose(input);
222 input = NULL;
223 }
224 if (dsi) {
225 daala_setup_free(dsi);
226 dsi = NULL;
227 }
228 if (dctx) {
229 daala_decode_free(dctx);
230 dctx = NULL;
231 }
232 ogg_sync_clear(&oy);
233 ogg_stream_clear(&os);
234 daala_info_clear(&di);
235 daala_comment_clear(&dc);
236 }
237
207 bool DaalaDecoder::step() { 238 bool DaalaDecoder::step() {
208 //fprintf(stderr, "reading frame %i\n", frame); 239 //fprintf(stderr, "reading frame %i\n", frame);
209 ogg_packet packet; 240 ogg_packet op;
210 if (readPacket(&packet)) { 241 daala_packet dp;
211 if (daala_decode_packet_in(dctx, &img, &packet) != 0) { 242 if (readPacket(&op)) {
243 ogg_to_daala_packet(&dp, &op);
244 if (daala_decode_packet_in(dctx, &img, &dp) != 0) {
212 return false; 245 return false;
213 } 246 }
214 frame++; 247 frame++;
215 return true; 248 return true;
216 } 249 }
217 return false; 250 return false;
218 } 251 }
219 252
220 // TODO: Move cleanup code from destructor to here 253 void DaalaDecoder::restart() {
221 void DaalaDecoder::reset() { 254 close();
255 daala_info_init(&di);
256 daala_comment_init(&dc);
257 open(path);
222 } 258 }
223 259
224 int DaalaDecoder::getWidth() const { 260 int DaalaDecoder::getWidth() const {
225 return di.pic_width; 261 return di.pic_width;
226 } 262 }
227 263
228 int DaalaDecoder::getHeight() const { 264 int DaalaDecoder::getHeight() const {
229 return di.pic_height; 265 return di.pic_height;
230 } 266 }
231 267
232 int DaalaDecoder::getFrameWidth() const { 268 int DaalaDecoder::getFrameWidth() const {
233 return di.pic_width + (OD_BSIZE_MAX - 1) & ~(OD_BSIZE_MAX - 1); 269 return di.pic_width + (2*OD_BSIZE_MAX - 1) & ~(2*OD_BSIZE_MAX - 1);
234 } 270 }
235 271
236 int DaalaDecoder::getFrameHeight() const { 272 int DaalaDecoder::getFrameHeight() const {
237 return di.pic_height + (OD_BSIZE_MAX - 1) & ~(OD_BSIZE_MAX - 1); 273 return di.pic_height + (2*OD_BSIZE_MAX - 1) & ~(2*OD_BSIZE_MAX - 1);
238 } 274 }
239 275
240 int DaalaDecoder::getRunningFrameCount() const { 276 int DaalaDecoder::getRunningFrameCount() const {
241 return frame; 277 return frame;
242 } 278 }
243 279
244 bool DaalaDecoder::setBlockSizeBuffer(unsigned char *buf, size_t buf_sz) { 280 bool DaalaDecoder::setBlockSizeBuffer(unsigned char *buf, size_t buf_sz) {
245 if (dctx == NULL) { 281 if (dctx == NULL) {
246 return false; 282 return false;
247 } 283 }
248 return daala_decode_ctl(dctx, OD_DECCTL_SET_BSIZE_BUFFER, buf, buf_sz) == 0; 284 return daala_decode_ctl(dctx, OD_DECCTL_SET_BSIZE_BUFFER, buf, buf_sz) ==
285 OD_SUCCESS;
249 } 286 }
250 287
251 bool DaalaDecoder::setBandFlagsBuffer(unsigned int *buf, size_t buf_sz) { 288 bool DaalaDecoder::setBandFlagsBuffer(unsigned int *buf, size_t buf_sz) {
252 if (dctx == NULL) { 289 if (dctx == NULL) {
253 return false; 290 return false;
254 } 291 }
255 return daala_decode_ctl(dctx, OD_DECCTL_SET_FLAGS_BUFFER, buf, buf_sz) == 0; 292 return daala_decode_ctl(dctx, OD_DECCTL_SET_FLAGS_BUFFER, buf, buf_sz) ==
293 OD_SUCCESS;
294 }
295
296 bool DaalaDecoder::setAccountingEnabled(bool enable) {
297 if (dctx == NULL) {
298 return false;
299 }
300 int e = enable ? 1 : 0;
301 return daala_decode_ctl(dctx, OD_DECCTL_SET_ACCOUNTING_ENABLED, &e,
302 sizeof(e)) == OD_SUCCESS;
303 }
304
305 bool DaalaDecoder::getAccountingStruct(od_accounting **acct) {
306 if (dctx == NULL) {
307 return false;
308 }
309 return
310 daala_decode_ctl(dctx, OD_DECCTL_GET_ACCOUNTING, acct, sizeof(acct)) ==
311 OD_SUCCESS;
312 }
313
314 bool DaalaDecoder::setDeringFlagsBuffer(unsigned char *buf, size_t buf_sz) {
315 if (dctx == NULL) {
316 return false;
317 }
318 return daala_decode_ctl(dctx, OD_DECCTL_SET_DERING_BUFFER, buf, buf_sz) ==
319 OD_SUCCESS;
256 } 320 }
257 321
258 #define MIN_ZOOM (1) 322 #define MIN_ZOOM (1)
259 #define MAX_ZOOM (4) 323 #define MAX_ZOOM (4)
260 324
261 enum { 325 enum {
262 OD_LUMA_MASK = 1 << 0, 326 OD_LUMA_MASK = 1 << 0,
263 OD_CB_MASK = 1 << 1, 327 OD_CB_MASK = 1 << 1,
264 OD_CR_MASK = 1 << 2, 328 OD_CR_MASK = 1 << 2,
265 OD_ALL_MASK = OD_LUMA_MASK | OD_CB_MASK | OD_CR_MASK 329 OD_ALL_MASK = OD_LUMA_MASK | OD_CB_MASK | OD_CR_MASK
266 }; 330 };
267 331
268 class TestPanel : public wxPanel { 332 class TestPanel : public wxPanel {
269 DECLARE_EVENT_TABLE() 333 DECLARE_EVENT_TABLE()
270 private: 334 private:
271 DaalaDecoder dd; 335 DaalaDecoder dd;
272 336
273 int zoom; 337 int zoom;
274 unsigned char *pixels; 338 unsigned char *pixels;
275 339
276 unsigned char *bsize; 340 unsigned char *bsize;
341 unsigned int bsize_len;
277 int bstride; 342 int bstride;
278 bool show_blocks; 343 bool show_blocks;
279 344
280 unsigned int *flags; 345 unsigned int *flags;
346 unsigned int flags_len;
281 int fstride; 347 int fstride;
282 bool show_skip; 348 bool show_skip;
283 bool show_noref; 349 bool show_noref;
284 bool show_padding; 350 bool show_padding;
351 bool show_dering;
352
353 od_accounting *acct;
354 bool show_bits;
355 double *bpp_q3;
356
357 unsigned char *dering;
358 unsigned int dering_len;
359
285 int plane_mask; 360 int plane_mask;
286 wxString path; 361 const wxString path;
287 362
288 // The decode size is the picture size or frame size. 363 // The decode size is the picture size or frame size.
289 int getDecodeWidth() const; 364 int getDecodeWidth() const;
290 int getDecodeHeight() const; 365 int getDecodeHeight() const;
291 366
292 // The display size is the decode size, scaled by the zoom. 367 // The display size is the decode size, scaled by the zoom.
293 int getDisplayWidth() const; 368 int getDisplayWidth() const;
294 int getDisplayHeight() const; 369 int getDisplayHeight() const;
295 370
296 bool updateDisplaySize(); 371 bool updateDisplaySize();
297 372
298 int getBand(int x, int y) const; 373 int getBand(int x, int y) const;
374 void computeBitsPerPixel();
299 public: 375 public:
300 TestPanel(wxWindow *parent, wxString &path); 376 TestPanel(wxWindow *parent, const wxString &path);
301 ~TestPanel(); 377 ~TestPanel();
302 378
303 bool open(const char *path); 379 bool open(const wxString &path);
304 void close(); 380 void close();
305 void render(); 381 void render();
306 bool nextFrame(); 382 bool nextFrame();
383 void refresh();
384 bool gotoFrame();
385 void restart();
307 386
308 int getZoom() const; 387 int getZoom() const;
309 bool setZoom(int zoom); 388 bool setZoom(int zoom);
310 389
311 void setShowBlocks(bool show_blocks); 390 void setShowBlocks(bool show_blocks);
312 void setShowSkip(bool show_skip); 391 void setShowSkip(bool show_skip);
313 void setShowNoRef(bool show_noref); 392 void setShowNoRef(bool show_noref);
314 void setShowPadding(bool show_padding); 393 void setShowPadding(bool show_padding);
394 void setShowBits(bool show_bits);
395 void setShowDering(bool show_dering);
315 void setShowPlane(bool show_plane, int mask); 396 void setShowPlane(bool show_plane, int mask);
316 397
317 bool hasPadding(); 398 bool hasPadding();
318 399
319 void onKeyDown(wxKeyEvent &event);
320 void onPaint(wxPaintEvent &event); 400 void onPaint(wxPaintEvent &event);
321 void onIdle(wxIdleEvent &event); 401 void onIdle(wxIdleEvent &event);
322 void onMouseMotion(wxMouseEvent &event); 402 void onMouseMotion(wxMouseEvent &event);
323 void onMouseLeaveWindow(wxMouseEvent &event); 403 void onMouseLeaveWindow(wxMouseEvent &event);
324 }; 404 };
325 405
326 BEGIN_EVENT_TABLE(TestPanel, wxPanel) 406 BEGIN_EVENT_TABLE(TestPanel, wxPanel)
327 EVT_KEY_DOWN(TestPanel::onKeyDown)
328 EVT_PAINT(TestPanel::onPaint) 407 EVT_PAINT(TestPanel::onPaint)
329 EVT_MOTION(TestPanel::onMouseMotion) 408 EVT_MOTION(TestPanel::onMouseMotion)
330 EVT_LEAVE_WINDOW(TestPanel::onMouseLeaveWindow) 409 EVT_LEAVE_WINDOW(TestPanel::onMouseLeaveWindow)
331 //EVT_IDLE(TestPanel::onIdle) 410 //EVT_IDLE(TestPanel::onIdle)
332 END_EVENT_TABLE() 411 END_EVENT_TABLE()
333 412
334 class TestFrame : public wxFrame { 413 class TestFrame : public wxFrame {
335 DECLARE_EVENT_TABLE() 414 DECLARE_EVENT_TABLE()
336 private: 415 private:
337 TestPanel *panel; 416 TestPanel *panel;
338 wxMenu *fileMenu; 417 wxMenu *fileMenu;
339 wxMenu *viewMenu; 418 wxMenu *viewMenu;
340 wxMenu *playbackMenu; 419 wxMenu *playbackMenu;
341 public: 420 public:
342 TestFrame(); 421 TestFrame();
343 422
344 void onOpen(wxCommandEvent &event); 423 void onOpen(wxCommandEvent &event);
345 void onClose(wxCommandEvent &event); 424 void onClose(wxCommandEvent &event);
346 void onQuit(wxCommandEvent &event); 425 void onQuit(wxCommandEvent &event);
347 void onZoomIn(wxCommandEvent &event); 426 void onZoomIn(wxCommandEvent &event);
348 void onZoomOut(wxCommandEvent &event); 427 void onZoomOut(wxCommandEvent &event);
349 void onFilter(wxCommandEvent &event); 428 void onFilter(wxCommandEvent &event);
350 void onPaddingChange(wxCommandEvent &event); 429 void onPaddingChange(wxCommandEvent &event);
430 void onBitsChange(wxCommandEvent &event);
351 void onYChange(wxCommandEvent &event); 431 void onYChange(wxCommandEvent &event);
352 void onUChange(wxCommandEvent &event); 432 void onUChange(wxCommandEvent &event);
353 void onVChange(wxCommandEvent &event); 433 void onVChange(wxCommandEvent &event);
354 void onNextFrame(wxCommandEvent &event); 434 void onNextFrame(wxCommandEvent &event);
435 void onGotoFrame(wxCommandEvent &event);
436 void onRestart(wxCommandEvent &event);
355 void onAbout(wxCommandEvent &event); 437 void onAbout(wxCommandEvent &event);
356 438
357 bool open(wxString path); 439 bool open(const wxString &path);
358 }; 440 };
359 441
360 enum { 442 enum {
361 wxID_SHOW_BLOCKS = 6000, 443 wxID_SHOW_BLOCKS = 6000,
362 wxID_SHOW_SKIP, 444 wxID_SHOW_SKIP,
363 wxID_SHOW_NOREF, 445 wxID_SHOW_NOREF,
364 wxID_SHOW_PADDING, 446 wxID_SHOW_PADDING,
447 wxID_SHOW_BITS,
448 wxID_SHOW_DERING,
365 wxID_SHOW_Y, 449 wxID_SHOW_Y,
366 wxID_SHOW_U, 450 wxID_SHOW_U,
367 wxID_SHOW_V, 451 wxID_SHOW_V,
368 wxID_NEXT_FRAME 452 wxID_NEXT_FRAME,
453 wxID_GOTO_FRAME,
454 wxID_RESTART
369 }; 455 };
370 456
371 BEGIN_EVENT_TABLE(TestFrame, wxFrame) 457 BEGIN_EVENT_TABLE(TestFrame, wxFrame)
372 EVT_MENU(wxID_OPEN, TestFrame::onOpen) 458 EVT_MENU(wxID_OPEN, TestFrame::onOpen)
373 EVT_MENU(wxID_CLOSE, TestFrame::onClose) 459 EVT_MENU(wxID_CLOSE, TestFrame::onClose)
374 EVT_MENU(wxID_EXIT, TestFrame::onQuit) 460 EVT_MENU(wxID_EXIT, TestFrame::onQuit)
375 EVT_MENU(wxID_ZOOM_IN, TestFrame::onZoomIn) 461 EVT_MENU(wxID_ZOOM_IN, TestFrame::onZoomIn)
376 EVT_MENU(wxID_ZOOM_OUT, TestFrame::onZoomOut) 462 EVT_MENU(wxID_ZOOM_OUT, TestFrame::onZoomOut)
377 EVT_MENU(wxID_SHOW_BLOCKS, TestFrame::onFilter) 463 EVT_MENU(wxID_SHOW_BLOCKS, TestFrame::onFilter)
378 EVT_MENU(wxID_SHOW_SKIP, TestFrame::onFilter) 464 EVT_MENU(wxID_SHOW_SKIP, TestFrame::onFilter)
379 EVT_MENU(wxID_SHOW_NOREF, TestFrame::onFilter) 465 EVT_MENU(wxID_SHOW_NOREF, TestFrame::onFilter)
380 EVT_MENU(wxID_SHOW_PADDING, TestFrame::onPaddingChange) 466 EVT_MENU(wxID_SHOW_PADDING, TestFrame::onPaddingChange)
467 EVT_MENU(wxID_SHOW_BITS, TestFrame::onBitsChange)
468 EVT_MENU(wxID_SHOW_DERING, TestFrame::onFilter)
381 EVT_MENU(wxID_SHOW_Y, TestFrame::onYChange) 469 EVT_MENU(wxID_SHOW_Y, TestFrame::onYChange)
382 EVT_MENU(wxID_SHOW_U, TestFrame::onUChange) 470 EVT_MENU(wxID_SHOW_U, TestFrame::onUChange)
383 EVT_MENU(wxID_SHOW_V, TestFrame::onVChange) 471 EVT_MENU(wxID_SHOW_V, TestFrame::onVChange)
384 EVT_MENU(wxID_NEXT_FRAME, TestFrame::onNextFrame) 472 EVT_MENU(wxID_NEXT_FRAME, TestFrame::onNextFrame)
473 EVT_MENU(wxID_GOTO_FRAME, TestFrame::onGotoFrame)
474 EVT_MENU(wxID_RESTART, TestFrame::onRestart)
385 EVT_MENU(wxID_ABOUT, TestFrame::onAbout) 475 EVT_MENU(wxID_ABOUT, TestFrame::onAbout)
386 END_EVENT_TABLE() 476 END_EVENT_TABLE()
387 477
388 TestPanel::TestPanel(wxWindow *parent, wxString &path) : wxPanel(parent), 478 TestPanel::TestPanel(wxWindow *parent, const wxString &path) : wxPanel(parent),
389 pixels(NULL), zoom(0), bsize(NULL), show_blocks(false), flags(NULL), 479 pixels(NULL), zoom(0), bsize(NULL), bsize_len(0), show_blocks(false),
390 show_skip(false), show_noref(false), show_padding(false), 480 flags(NULL), flags_len(0), show_skip(false), show_noref(false),
391 plane_mask(OD_ALL_MASK), path(path) { 481 show_padding(false), show_dering(false), acct(NULL), show_bits(false),
482 bpp_q3(NULL), dering(NULL), dering_len(0), plane_mask(OD_ALL_MASK),
483 path(path) {
392 } 484 }
393 485
394 TestPanel::~TestPanel() { 486 TestPanel::~TestPanel() {
395 close(); 487 close();
396 } 488 }
397 489
398 bool TestPanel::open(const char *path) { 490 bool TestPanel::open(const wxString &path) {
399 if (!dd.open(path)) { 491 if (!dd.open(path)) {
400 return false; 492 return false;
401 } 493 }
402 if (!setZoom(MIN_ZOOM)) { 494 if (!setZoom(MIN_ZOOM)) {
403 return false; 495 return false;
404 } 496 }
405 int nhsb = dd.getFrameWidth() >> OD_LOG_BSIZE0 + OD_NBSIZES - 1; 497 int nhsb = dd.getFrameWidth() >> OD_LOG_BSIZE0 + OD_NBSIZES - 1;
406 int nvsb = dd.getFrameHeight() >> OD_LOG_BSIZE0 + OD_NBSIZES - 1; 498 int nvsb = dd.getFrameHeight() >> OD_LOG_BSIZE0 + OD_NBSIZES - 1;
407 bsize = (unsigned char *)malloc(sizeof(*bsize)*nhsb*4*nvsb*4); 499 bsize_len = sizeof(*bsize)*nhsb*4*nvsb*4;
500 bsize = (unsigned char *)malloc(bsize_len);
408 if (bsize == NULL) { 501 if (bsize == NULL) {
502 bsize_len = 0;
409 close(); 503 close();
410 return false; 504 return false;
411 } 505 }
412 bstride = nhsb*4; 506 bstride = nhsb*4;
413 if (!dd.setBlockSizeBuffer(bsize, sizeof(*bsize)*nhsb*4*nvsb*4)) { 507 if (!dd.setBlockSizeBuffer(bsize, bsize_len)) {
414 close(); 508 close();
415 return false; 509 return false;
416 } 510 }
417 flags = (unsigned int *)malloc(sizeof(*flags)*nhsb*8*nvsb*8); 511 flags_len = sizeof(*flags)*nhsb*8*nvsb*8;
512 flags = (unsigned int *)malloc(flags_len);
418 if (flags == NULL) { 513 if (flags == NULL) {
514 flags_len = 0;
419 fprintf(stderr,"Could not allocate memory\n"); 515 fprintf(stderr,"Could not allocate memory\n");
420 close(); 516 close();
421 return false; 517 return false;
422 } 518 }
423 fstride = nhsb*8; 519 fstride = nhsb*8;
424 if (!dd.setBandFlagsBuffer(flags, sizeof(unsigned int)*nhsb*8*nvsb*8)) { 520 if (!dd.setBandFlagsBuffer(flags, flags_len)) {
425 fprintf(stderr,"Could not set flags buffer\n"); 521 fprintf(stderr,"Could not set flags buffer\n");
426 close(); 522 close();
427 return false; 523 return false;
428 } 524 }
525 bpp_q3 =
526 (double *)malloc(sizeof(*bpp_q3)*dd.getFrameWidth()*dd.getFrameHeight());
527 if (!dd.setAccountingEnabled(true)) {
528 fprintf(stderr, "Could not enable accounting\n");
529 close();
530 return false;
531 }
532 if (!dd.getAccountingStruct(&acct)) {
533 fprintf(stderr,"Could not get accounting struct\n");
534 close();
535 return false;
536 }
537 dering_len = nhsb*nvsb;
538 dering = (unsigned char *)malloc(dering_len);
539 if (!dd.setDeringFlagsBuffer(dering, dering_len)) {
540 fprintf(stderr,"Could not set dering flags buffer\n");
541 close();
542 return false;
543 }
429 if (!nextFrame()) { 544 if (!nextFrame()) {
430 close(); 545 close();
431 return false; 546 return false;
432 } 547 }
433 SetFocus(); 548 SetFocus();
434 return true; 549 return true;
435 } 550 }
436 551
437 void TestPanel::close() { 552 void TestPanel::close() {
438 dd.reset(); 553 dd.close();
439 free(pixels); 554 free(pixels);
440 pixels = NULL; 555 pixels = NULL;
441 free(bsize); 556 free(bsize);
442 bsize = NULL; 557 bsize = NULL;
443 free(flags); 558 free(flags);
444 flags = NULL; 559 flags = NULL;
560 free(bpp_q3);
561 bpp_q3 = NULL;
562 free(dering);
563 dering = NULL;
445 } 564 }
446 565
447 int TestPanel::getDecodeWidth() const { 566 int TestPanel::getDecodeWidth() const {
448 return show_padding ? dd.getFrameWidth() : dd.getWidth(); 567 return show_padding ? dd.getFrameWidth() : dd.getWidth();
449 } 568 }
450 569
451 int TestPanel::getDecodeHeight() const { 570 int TestPanel::getDecodeHeight() const {
452 return show_padding ? dd.getFrameHeight() : dd.getHeight(); 571 return show_padding ? dd.getFrameHeight() : dd.getHeight();
453 } 572 }
454 573
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 int w; 606 int w;
488 int h; 607 int h;
489 int x; 608 int x;
490 int y; 609 int y;
491 int i; 610 int i;
492 int u_hdec; 611 int u_hdec;
493 int u_vdec; 612 int u_vdec;
494 int v_hdec; 613 int v_hdec;
495 int v_vdec; 614 int v_vdec;
496 cairo_surface_t *cs; 615 cairo_surface_t *cs;
497 unsigned char * pixels; 616 unsigned char * pixels;
tmatth 2015/07/28 16:09:26 unsigned char *pixels;
498 617
499 w=img->width; 618 w=img->width;
500 h=img->height; 619 h=img->height;
501 u_hdec=img->planes[1].xdec; 620 u_hdec=img->planes[1].xdec;
502 u_vdec=img->planes[1].ydec; 621 u_vdec=img->planes[1].ydec;
503 v_hdec=img->planes[2].xdec; 622 v_hdec=img->planes[2].xdec;
504 v_vdec=img->planes[2].ydec; 623 v_vdec=img->planes[2].ydec;
505 y_row=img->planes[0].data; 624 y_row=img->planes[0].data;
506 u_row=img->planes[1].data; 625 u_row=img->planes[1].data;
507 v_row=img->planes[2].data; 626 v_row=img->planes[2].data;
tmatth 2015/07/28 16:09:26 needs spaces around assignment operator
508 627
509 pixels = (unsigned char *)malloc(sizeof(*pixels)*4*w*h); 628 pixels = (unsigned char *)malloc(sizeof(*pixels)*4*w*h);
510 629
511 /* convert the YUV image into our xRGB pixels buffer (Cairo requires 630 /* convert the YUV image into our xRGB pixels buffer (Cairo requires
512 unpacked 32 bit RGB with one unused byte). This code works for 631 unpacked 32 bit RGB with one unused byte). This code works for
513 420, 422 and 444 */ 632 420, 422 and 444 */
514 xrgb = pixels; 633 xrgb = pixels;
515 for(y=0;y<h;y++){ 634 for(y=0;y<h;y++){
tmatth 2015/07/28 16:09:26 for (y = 0; y < h; y++) {
516 for(x=0;x<w;x++){ 635 for(x=0;x<w;x++){
tmatth 2015/07/28 16:09:26 for (x = 0; x < w; x++) {
517 unsigned int r; 636 unsigned int r;
518 unsigned int g; 637 unsigned int g;
519 unsigned int b; 638 unsigned int b;
520 int64_t yval; 639 int64_t yval;
521 int64_t cbval; 640 int64_t cbval;
522 int64_t crval; 641 int64_t crval;
523 yval = y_row[x] - 16; 642 yval = y_row[x] - 16;
524 cbval = u_row[x>>u_hdec] - 128; 643 cbval = u_row[x>>u_hdec] - 128;
tmatth 2015/07/28 16:09:27 spaces around shift operator
525 crval = v_row[x>>v_hdec] - 128; 644 crval = v_row[x>>v_hdec] - 128;
tmatth 2015/07/28 16:09:27 spaces around shift operator
526 r = OD_CLAMPI(0, (int32_t)OD_DIV_ROUND( 645 r = OD_CLAMPI(0, (int32_t)OD_DIV_ROUND(
527 2916394880000LL*yval + 4490222169144LL*crval, 9745792000LL), 65535); 646 2916394880000LL*yval + 4490222169144LL*crval, 9745792000LL), 65535);
528 g = OD_CLAMPI(0, (int32_t)OD_DIV_ROUND( 647 g = OD_CLAMPI(0, (int32_t)OD_DIV_ROUND(
529 2916394880000LL*yval - 534117096223LL*cbval - 1334761232047LL*crval, 648 2916394880000LL*yval - 534117096223LL*cbval - 1334761232047LL*crval,
530 9745792000LL), 65535); 649 9745792000LL), 65535);
531 b = OD_CLAMPI(0, (int32_t)OD_DIV_ROUND( 650 b = OD_CLAMPI(0, (int32_t)OD_DIV_ROUND(
532 2916394880000LL*yval + 5290866304968LL*cbval, 9745792000LL), 65535); 651 2916394880000LL*yval + 5290866304968LL*cbval, 9745792000LL), 65535);
533 xrgb[4*x+0] = (unsigned char)(b >> 8); 652 xrgb[4*x+0] = (unsigned char)(b >> 8);
534 xrgb[4*x+1] = (unsigned char)(g >> 8); 653 xrgb[4*x+1] = (unsigned char)(g >> 8);
535 xrgb[4*x+2] = (unsigned char)(r >> 8); 654 xrgb[4*x+2] = (unsigned char)(r >> 8);
536 xrgb[4*x+3] = 0; 655 xrgb[4*x+3] = 0;
tmatth 2015/07/28 16:09:27 spaces around + operators
537 } 656 }
538 y_row+=img->planes[0].ystride; 657 y_row+=img->planes[0].ystride;
539 u_row+=img->planes[1].ystride&-((y&1)|!u_vdec); 658 u_row+=img->planes[1].ystride&-((y&1)|!u_vdec);
540 v_row+=img->planes[2].ystride&-((y&1)|!v_vdec); 659 v_row+=img->planes[2].ystride&-((y&1)|!v_vdec);
tmatth 2015/07/28 16:09:27 spaces around += and I believe spaces around & and
541 xrgb+=4*w; 660 xrgb+=4*w;
tmatth 2015/07/28 16:09:27 spaces around +=
542 } 661 }
543 662
544 /* hand pixels to Cairo */ 663 /* hand pixels to Cairo */
545 cs=cairo_image_surface_create_for_data(pixels,CAIRO_FORMAT_ARGB32,w,h,w*4); 664 cs=cairo_image_surface_create_for_data(pixels,CAIRO_FORMAT_ARGB32,w,h,w*4);
tmatth 2015/07/28 16:09:27 spaces around = and spaces after commas
546 if(cairo_surface_status(cs)!=CAIRO_STATUS_SUCCESS){ 665 if(cairo_surface_status(cs)!=CAIRO_STATUS_SUCCESS){
tmatth 2015/07/28 16:09:27 if (cairo_surface_status(cs) != CAIRO_STATUS_SUCCE
547 cairo_surface_destroy(cs); 666 cairo_surface_destroy(cs);
548 return NULL; 667 return NULL;
549 } 668 }
550 return cs; 669 return cs;
551 } 670 }
552 671
553 void TestPanel::render() { 672 void TestPanel::render() {
554 od_img *img = img_clone(&dd.img); 673 od_img *img = img_clone(&dd.img);
555 cairo_surface_t *cs; 674 cairo_surface_t *cs;
675 cairo_t *cr;
676 cairo_pattern_t *p;
677 cairo_surface_t *output_surface;
556 /* Assume both chroma planes are decimated the same */ 678 /* Assume both chroma planes are decimated the same */
557 int xdec = img->planes[1].xdec; 679 int xdec = img->planes[1].xdec;
558 int ydec = img->planes[1].ydec; 680 int ydec = img->planes[1].ydec;
559 int y_stride = img->planes[0].ystride; 681 int y_stride = img->planes[0].ystride;
560 int cb_stride = img->planes[1].ystride; 682 int cb_stride = img->planes[1].ystride;
561 int cr_stride = img->planes[2].ystride; 683 int cr_stride = img->planes[2].ystride;
562 int p_stride = 3*getDisplayWidth(); 684 int p_stride = 3*getDisplayWidth();
563 unsigned char *y_row = img->planes[0].data; 685 unsigned char *y_row = img->planes[0].data;
564 unsigned char *cb_row = img->planes[1].data; 686 unsigned char *cb_row = img->planes[1].data;
565 unsigned char *cr_row = img->planes[2].data; 687 unsigned char *cr_row = img->planes[2].data;
566 unsigned char *p_row = pixels; 688 unsigned char *p_row = pixels;
689 double maxval=0;
690 double norm;
691 int nhsb = dd.getFrameWidth() >> OD_LOG_BSIZE0 + OD_NBSIZES - 1;
692 for (int j = 0; j < getDecodeHeight(); j++) {
693 for (int i = 0; i < getDecodeWidth(); i++) {
694 double bpp = bpp_q3[j*dd.getFrameWidth() + i];
695 if (bpp > maxval) maxval = bpp;
696 }
697 }
698 norm = 1./(1e-4+maxval);
567 for (int j = 0; j < getDecodeHeight(); j++) { 699 for (int j = 0; j < getDecodeHeight(); j++) {
568 unsigned char *y = y_row; 700 unsigned char *y = y_row;
569 unsigned char *cb = cb_row; 701 unsigned char *cb = cb_row;
570 unsigned char *cr = cr_row; 702 unsigned char *cr = cr_row;
571 unsigned char *p = p_row; 703 unsigned char *p = p_row;
572 for (int i = 0; i < getDecodeWidth(); i++) { 704 for (int i = 0; i < getDecodeWidth(); i++) {
573 ogg_int64_t yval; 705 ogg_int64_t yval;
574 ogg_int64_t cbval; 706 ogg_int64_t cbval;
575 ogg_int64_t crval; 707 ogg_int64_t crval;
576 unsigned rval; 708 unsigned rval;
(...skipping 24 matching lines...) Expand all
601 if ((!skip || !show_skip) && noref && show_noref) { 733 if ((!skip || !show_skip) && noref && show_noref) {
602 cbval = 84; 734 cbval = 84;
603 crval = 255; 735 crval = 255;
604 } 736 }
605 if (skip && show_skip && (!noref || !show_noref)) { 737 if (skip && show_skip && (!noref || !show_noref)) {
606 cbval = 255; 738 cbval = 255;
607 crval = 107; 739 crval = 107;
608 } 740 }
609 } 741 }
610 } 742 }
743 if (show_bits) {
744 double bpp = sqrt(bpp_q3[j*dd.getFrameWidth() + i]*norm);
745 #if 1 /* Make this zero for an alternate colormap. */
746 double theta = 2*M_PI*bpp;
747 double radius = 1.2*sqrt(bpp);
748 cbval = 128 + (int64_t)(127*radius*cos(theta));
749 crval = 128 - (int64_t)(127*radius*sin(theta));
750 if (cbval < 0) cbval = 0;
751 if (cbval > 255) cbval = 255;
752 if (crval < 0) crval = 0;
753 if (crval > 255) crval = 255;
754 #else
755 bpp *= 9;
756 if (bpp < 2) {
757 cbval = 128 + (int64_t)(63*bpp);
758 crval = 128 - (int64_t)(63*bpp);
759 }
760 else if (bpp < 4) {
761 bpp -= 2;
762 cbval = 255 - (int64_t)(127*bpp);
763 crval = 0;
764 }
765 else if (bpp < 6) {
766 bpp -= 4;
767 cbval = 0;
768 crval = (int64_t)(127*bpp);
769 }
770 else if (bpp < 8) {
771 bpp -= 6;
772 cbval = (int64_t)(127*bpp);
773 crval = 255;
774 }
775 else if (bpp < 9) {
776 bpp -= 8;
777 cbval = 255;
778 crval = 255 - (int64_t)(127*bpp);
779 }
780 #endif
781 }
782 if (show_dering) {
783 int sbx;
784 int sby;
785 sbx = i >> OD_LOG_BSIZE0 + OD_NBSIZES - 1;
786 sby = j >> OD_LOG_BSIZE0 + OD_NBSIZES - 1;
787 if (dering[sby*nhsb + sbx]) {
788 yval = 0;
789 }
790 }
611 if (show_blocks) { 791 if (show_blocks) {
612 unsigned char d = OD_BLOCK_SIZE4x4(bsize, bstride, i >> 2, j >> 2); 792 unsigned char d = OD_BLOCK_SIZE4x4(bsize, bstride, i >> 2, j >> 2);
613 int mask = (1 << d + OD_LOG_BSIZE0) - 1; 793 int mask = (1 << d + OD_LOG_BSIZE0) - 1;
614 if (!(i & mask) || !(j & mask)) { 794 if (!(i & mask) || !(j & mask)) {
615 yval = block_edge_luma(yval); 795 yval = block_edge_luma(yval);
616 cbval = (cbval + 128) >> 1; 796 cbval = (cbval + 128) >> 1;
617 crval = (crval + 128) >> 1; 797 crval = (crval + 128) >> 1;
618 pmask = OD_ALL_MASK; 798 pmask = OD_ALL_MASK;
619 } 799 }
620 } 800 }
621 if (i == dd.getWidth() || j == dd.getHeight()) { 801 if (i == dd.getWidth() || j == dd.getHeight()) {
622 /* Display a checkerboard pattern at the padding edge */ 802 /* Display a checkerboard pattern at the padding edge */
623 yval = 255 * ((i + j) & 1); 803 yval = 255 * ((i + j) & 1);
624 pmask = OD_ALL_MASK; 804 pmask = OD_ALL_MASK;
625 } 805 }
626 if (!(pmask & OD_LUMA_MASK)) { 806 if (!(pmask & OD_LUMA_MASK)) {
627 yval = 144; 807 yval = 144;
628 } 808 }
629 cbval = ((pmask & OD_CB_MASK) >> 1) * (cbval); 809 cbval = ((pmask & OD_CB_MASK) >> 1) * (cbval);
630 crval = ((pmask & OD_CR_MASK) >> 2) * (crval); 810 crval = ((pmask & OD_CR_MASK) >> 2) * (crval);
tmatth 2015/07/28 16:09:27 no spaces around * operators
631 *y = OD_CLAMPI(16,yval,235); 811 *y = OD_CLAMPI(16,yval,235);
632 *cb = OD_CLAMPI(16,cbval,235); 812 *cb = OD_CLAMPI(16,cbval,235);
633 *cr = OD_CLAMPI(16,crval,235); 813 *cr = OD_CLAMPI(16,crval,235);
tmatth 2015/07/28 16:09:27 spaces after commas.
tmatth 2015/08/11 11:28:33 Around here is where luma gets broken, the minimum
634 int dc = ((y - y_row) & 1) | (1 - xdec); 814 int dc = ((y - y_row) & 1) | (1 - xdec);
635 y++; 815 y++;
636 cb += dc; 816 cb += dc;
637 cr += dc; 817 cr += dc;
638 } 818 }
639 int dc = -((j & 1) | (1 - ydec)); 819 int dc = -((j & 1) | (1 - ydec));
640 y_row += y_stride; 820 y_row += y_stride;
641 cb_row += dc & cb_stride; 821 cb_row += dc & cb_stride;
642 cr_row += dc & cr_stride; 822 cr_row += dc & cr_stride;
643 } 823 }
644 cs = create_from_img(img); 824 cs = create_from_img(img);
645 cairo_surface_flush(cs); 825 cairo_surface_flush(cs);
646 unsigned char *cairo_pixels = cairo_image_surface_get_data(cs); 826 output_surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
827 getDisplayWidth(), getDisplayHeight());
828 cr = cairo_create(output_surface);
829 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
830 cairo_scale(cr, zoom, zoom);
831 cairo_set_source_surface (cr, cs, 0, 0);
832 p = cairo_get_source(cr);
833 cairo_pattern_set_filter(p, CAIRO_FILTER_NEAREST);
834 cairo_paint(cr);
835 cairo_surface_flush(output_surface);
836 unsigned char *cairo_pixels = cairo_image_surface_get_data(output_surface);
647 unsigned char *wx_pixels = pixels; 837 unsigned char *wx_pixels = pixels;
648 for(int i = 0; i < dd.getWidth()*dd.getHeight(); i++){ 838 for(int i = 0; i < getDisplayWidth()*getDisplayHeight(); i++){
649 *wx_pixels++ = cairo_pixels[2]; 839 *wx_pixels++ = cairo_pixels[2];
650 *wx_pixels++ = cairo_pixels[1]; 840 *wx_pixels++ = cairo_pixels[1];
651 *wx_pixels++ = cairo_pixels[0]; 841 *wx_pixels++ = cairo_pixels[0];
652 cairo_pixels += 4; 842 cairo_pixels += 4;
653 } 843 }
844 cairo_destroy(cr);
654 cairo_surface_destroy(cs); 845 cairo_surface_destroy(cs);
846 cairo_surface_destroy(output_surface);
655 } 847 }
656 848
657 int TestPanel::getZoom() const { 849 int TestPanel::getZoom() const {
658 return zoom; 850 return zoom;
659 } 851 }
660 852
661 bool TestPanel::updateDisplaySize() { 853 bool TestPanel::updateDisplaySize() {
662 unsigned char *p = 854 unsigned char *p =
663 (unsigned char *)malloc(sizeof(*p)*3*getDisplayWidth()*getDisplayHeight()); 855 (unsigned char *)malloc(sizeof(*p)*3*getDisplayWidth()*getDisplayHeight());
664 if (p == NULL) { 856 if (p == NULL) {
(...skipping 27 matching lines...) Expand all
692 } 884 }
693 885
694 void TestPanel::setShowPadding(bool show_padding) { 886 void TestPanel::setShowPadding(bool show_padding) {
695 bool old_show_padding = show_padding; 887 bool old_show_padding = show_padding;
696 this->show_padding = show_padding; 888 this->show_padding = show_padding;
697 if (!updateDisplaySize()) { 889 if (!updateDisplaySize()) {
698 this->show_padding = old_show_padding; 890 this->show_padding = old_show_padding;
699 } 891 }
700 } 892 }
701 893
894 void TestPanel::setShowBits(bool show_bits) {
895 this->show_bits = show_bits;
896 }
897
898 void TestPanel::setShowDering(bool show_dering) {
899 this->show_dering = show_dering;
900 }
901
702 void TestPanel::setShowPlane(bool show_plane, int mask) { 902 void TestPanel::setShowPlane(bool show_plane, int mask) {
703 if (show_plane) { 903 if (show_plane) {
704 plane_mask |= mask; 904 plane_mask |= mask;
705 } else { 905 } else {
706 plane_mask &= ~mask; 906 plane_mask &= ~mask;
707 } 907 }
708 } 908 }
709 909
710 bool TestPanel::hasPadding() { 910 bool TestPanel::hasPadding() {
711 return dd.getFrameWidth() > dd.getWidth() || 911 return dd.getFrameWidth() > dd.getWidth() ||
712 dd.getFrameHeight() > dd.getHeight(); 912 dd.getFrameHeight() > dd.getHeight();
713 } 913 }
714 914
715 void TestPanel::setShowNoRef(bool show_noref) { 915 void TestPanel::setShowNoRef(bool show_noref) {
716 this->show_noref = show_noref; 916 this->show_noref = show_noref;
717 } 917 }
718 918
919 void TestPanel::computeBitsPerPixel() {
920 int i, j;
921 double bpp_total;
922 int totals_q3[MAX_SYMBOL_TYPES] = {0};
923 for (j = 0; j < dd.getFrameHeight(); j++) {
924 for (i = 0; i < dd.getFrameWidth(); i++) {
925 bpp_q3[j*dd.getFrameWidth() + i] = 0;
926 }
927 }
928 bpp_total = 0;
929 for (i = 0; i < acct->nb_syms; i++) {
930 od_acct_symbol *s;
931 s = &acct->syms[i];
932 totals_q3[s->id] += s->bits_q3;
933 switch (s->layer) {
934 case 0:
935 case 1:
936 case 2:
937 case 3: {
938 int n, u, v;
939 double bpp;
940 n = 1 << (s->level + 2);
941 bpp = ((double)s->bits_q3)/(n*n);
942 for (v = 0; v < n; v++) {
943 for (u = 0; u < n; u++) {
944 bpp_q3[dd.getFrameWidth()*((s->y << 2) + u) + ((s->x << 2) + v)] +=
945 bpp;
946 bpp_total += bpp;
947 }
948 }
949 break;
950 }
951 case OD_ACCT_MV: {
952 if ((s->level & 1) == 0) {
953 /* Even-level MVs*/
954 int n = 32 >> (s->level/2);
955 int x, y;
956 int x0;
957 int y0;
958 int x1;
959 int y1;
960 double n_4 = 1./(n*n*n*n);
961 x0 = 4*s->x - (n - 1);
962 x1 = 4*s->x + (n - 1);
963 y0 = 4*s->y - (n - 1);
964 y1 = 4*s->y + (n - 1);
965 if (x0 < 0) x0 = 0;
966 if (y0 < 0) y0 = 0;
967 if (x1 >= dd.getFrameWidth()) x1 = dd.getFrameWidth() - 1;
968 if (y1 >= dd.getFrameHeight()) y1 = dd.getFrameHeight() - 1;
969 int bits = ((double)s->bits_q3);
970 for (y = y0; y <= y1; y++) {
971 for (x = x0; x <= x1; x++) {
972 /* We spread the bits as (1-x)*(1-y) like the bilinear blending.
973 FIXME: Do exact normalization when we're on the border of the
974 image. */
975 bpp_q3[dd.getFrameWidth()*y + x] +=
976 bits*(n - abs(x - 4*s->x))*(n - abs(y - 4*s->y))*n_4;
977 bpp_total += bpp_q3[dd.getFrameWidth()*y + x];
978 }
979 }
980 }
981 else {
982 /* Odd-level MVs. */
983 int n = 32 >> ((1 + s->level)/2);
984 int x, y;
985 int x0;
986 int y0;
987 int x1;
988 int y1;
989 double n_2 = 1./((2*n + 1)*(2*n + 1));
990 x0 = 4*s->x - (n - 1);
991 x1 = 4*s->x + (n - 1);
992 y0 = 4*s->y - (n - 1);
993 y1 = 4*s->y + (n - 1);
994 if (x0 < 0) x0 = 0;
995 if (y0 < 0) y0 = 0;
996 if (x1 >= dd.getFrameWidth()) x1 = dd.getFrameWidth() - 1;
997 if (y1 >= dd.getFrameHeight()) y1 = dd.getFrameHeight() - 1;
998 int bits = ((double)s->bits_q3);
999 for (y = y0; y <= y1; y++) {
1000 for (x = x0; x <= x1; x++) {
1001 /* FIXME: Spread the bits in the same was as the blending instead
1002 of as a square. */
1003 bpp_q3[dd.getFrameWidth()*y + x] +=
1004 bits*n_2;
1005 bpp_total += bpp_q3[dd.getFrameWidth()*y + x];
1006 }
1007 }
1008
1009 }
1010 break;
1011 }
1012 }
1013 }
1014 fprintf(stderr, "=== Frame: %-3i ==========================\n", dd.frame - 1);
1015 j = 0;
1016 /* Find max total. */
1017 for (i = 1; i < acct->dict.nb_str; i++) {
1018 if (totals_q3[i] > totals_q3[j]) {
1019 j = i;
1020 }
1021 }
1022 for (i = 0; i < acct->dict.nb_str; i++) {
1023 if (i == j) fprintf(stderr, "\033[1;31m");
1024 fprintf(stderr, "%20s = %10.3f %5.2f %%\n", acct->dict.str[i],
1025 (float)totals_q3[i]/8, totals_q3[i]/bpp_total*100);
1026 if (i == j) fprintf(stderr, "\033[0m");
1027 }
1028 fprintf(stderr, "%20s = %10.3i\n", "nb_syms", acct->nb_syms);
1029 fprintf(stderr, "%20s = %10.3f\n", "bpp_total", (float)bpp_total/8);
1030 }
1031 void TestPanel::refresh() {
1032 computeBitsPerPixel();
1033 render();
1034 ((TestFrame *)GetParent())->SetTitle(path +
1035 wxString::Format(wxT(" (%d,%d) Frame %d - Daala Stream Analyzer"),
1036 dd.getWidth(), dd.getHeight(), dd.getRunningFrameCount()-1));
1037 }
719 bool TestPanel::nextFrame() { 1038 bool TestPanel::nextFrame() {
720 if (dd.step()) { 1039 if (dd.step()) {
721 render(); 1040 /* For now just compute the unfiltered bits per pixel. */
722 ((TestFrame *)GetParent())->SetTitle(path + 1041 refresh();
723 wxString::Format(wxT(" (%d,%d) Frame %d - Daala Stream Analyzer"),
724 dd.getWidth(), dd.getHeight(), dd.getRunningFrameCount()-1));
725 return true; 1042 return true;
726 } 1043 }
727 return false; 1044 return false;
728 } 1045 }
729 1046
730 void TestPanel::onKeyDown(wxKeyEvent &event) { 1047 bool TestPanel::gotoFrame() {
731 switch (event.GetKeyCode()) { 1048 bool toReturn;
732 case '.' : { 1049 int nframe;
733 nextFrame(); 1050 wxTextEntryDialog dlg(this, _T("Jump to which frame?"));
734 Refresh(false); 1051 dlg.SetTextValidator(wxFILTER_NUMERIC);
735 break; 1052 if (dlg.ShowModal() == wxID_OK) {
736 } 1053 nframe = wxAtoi(dlg.GetValue());
737 } 1054 }
1055 else {
1056 return false;
1057 }
1058 if (nframe < dd.frame) {
1059 restart();
1060 }
1061 if(nframe <= 0) {
1062 return true;
1063 }
1064 if(nframe == dd.frame+1) {
1065 return nextFrame();
1066 }
1067 while (nframe >= dd.frame) {
1068 toReturn = dd.step();
1069 if (!toReturn) {
1070 wxMessageBox(_T("Error: Video doesn't have that many frames"));
1071 restart();
1072 return false;
1073 » }
1074 }
1075 refresh();
1076 return toReturn;
1077 }
1078
1079 void TestPanel::restart() {
1080 dd.restart();
1081 dd.setBlockSizeBuffer(bsize, bsize_len);
1082 dd.setBandFlagsBuffer(flags, flags_len);
1083 dd.setAccountingEnabled(true);
1084 dd.getAccountingStruct(&acct);
1085 dd.setDeringFlagsBuffer(dering, dering_len);
1086 nextFrame();
738 } 1087 }
739 1088
740 void TestPanel::onMouseMotion(wxMouseEvent& event) { 1089 void TestPanel::onMouseMotion(wxMouseEvent& event) {
741 const wxPoint pt = wxGetMousePosition(); 1090 const wxPoint pt = wxGetMousePosition();
742 int mouse_x = pt.x - this->GetScreenPosition().x; 1091 int mouse_x = pt.x - this->GetScreenPosition().x;
743 int mouse_y = pt.y - this->GetScreenPosition().y; 1092 int mouse_y = pt.y - this->GetScreenPosition().y;
744 TestFrame *parent = static_cast<TestFrame*>(GetParent()); 1093 TestFrame *parent = static_cast<TestFrame*>(GetParent());
745 int row = mouse_y/zoom; 1094 int row = mouse_y/zoom;
746 int col = mouse_x/zoom; 1095 int col = mouse_x/zoom;
747 if (row >= 0 && col >= 0 && row < getDecodeHeight() 1096 if (row >= 0 && col >= 0 && row < getDecodeHeight()
748 && col < getDecodeWidth()) { 1097 && col < getDecodeWidth()) {
749 const od_img_plane *planes = dd.img.planes; 1098 const od_img_plane *planes = dd.img.planes;
750 /* Assume both chroma planes are decimated the same */ 1099 /* Assume both chroma planes are decimated the same */
751 int xdec = planes[1].xdec; 1100 int xdec = planes[1].xdec;
752 int ydec = planes[1].ydec; 1101 int ydec = planes[1].ydec;
753 int cb_stride = planes[1].ystride; 1102 int cb_stride = planes[1].ystride;
754 int cr_stride = planes[2].ystride; 1103 int cr_stride = planes[2].ystride;
755 ogg_int64_t y = planes[0].data[planes[0].ystride*row + col]; 1104 ogg_int64_t y = planes[0].data[planes[0].ystride*row + col];
756 ogg_int64_t cb = planes[1].data[cb_stride*(row >> ydec) + (col >> xdec)]; 1105 ogg_int64_t cb = planes[1].data[cb_stride*(row >> ydec) + (col >> xdec)];
757 ogg_int64_t cr = planes[2].data[cr_stride*(row >> ydec) + (col >> xdec)]; 1106 ogg_int64_t cr = planes[2].data[cr_stride*(row >> ydec) + (col >> xdec)];
758 parent->SetStatusText(wxString::Format(wxT("Y:%lld,U:%lld,V:%lld"), 1107 parent->SetStatusText(wxString::Format(wxT("Y:%lld,U:%lld,V:%lld"),
759 y, cb, cr), 1); 1108 y, cb, cr), 1);
760 } else { 1109 } else {
761 parent->SetStatusText(wxString::Format(wxT("")), 1); 1110 parent->SetStatusText(wxString::Format(wxT("")), 1);
762 } 1111 }
763 parent->SetStatusText(wxString::Format(wxT("X:%d,Y:%d"), 1112 parent->SetStatusText(wxString::Format(wxT("X:%d,Y:%d"),
764 mouse_x, mouse_y), 2); 1113 col, row), 2);
765 } 1114 }
766 1115
767 void TestPanel::onMouseLeaveWindow(wxMouseEvent& event) { 1116 void TestPanel::onMouseLeaveWindow(wxMouseEvent& event) {
768 TestFrame *parent = static_cast<TestFrame*>(GetParent()); 1117 TestFrame *parent = static_cast<TestFrame*>(GetParent());
769 parent->SetStatusText(wxString::Format(wxT("")), 1); 1118 parent->SetStatusText(wxString::Format(wxT("")), 1);
770 } 1119 }
771 1120
772 void TestPanel::onPaint(wxPaintEvent &) { 1121 void TestPanel::onPaint(wxPaintEvent &) {
773 wxBitmap bmp(wxImage(getDisplayWidth(), getDisplayHeight(), pixels, true)); 1122 wxBitmap bmp(wxImage(getDisplayWidth(), getDisplayHeight(), pixels, true));
774 wxBufferedPaintDC dc(this, bmp); 1123 wxBufferedPaintDC dc(this, bmp);
775 } 1124 }
776 1125
777 void TestPanel::onIdle(wxIdleEvent &) { 1126 void TestPanel::onIdle(wxIdleEvent &) {
778 nextFrame(); 1127 nextFrame();
779 Refresh(false); 1128 Refresh(false);
(...skipping 17 matching lines...) Expand all
797 viewMenu->Append(wxID_ZOOM_OUT, _T("Zoom-Out\tCtrl--"), 1146 viewMenu->Append(wxID_ZOOM_OUT, _T("Zoom-Out\tCtrl--"),
798 _T("Half image size")); 1147 _T("Half image size"));
799 viewMenu->AppendCheckItem(wxID_SHOW_BLOCKS, _T("&Blocks\tCtrl-B"), 1148 viewMenu->AppendCheckItem(wxID_SHOW_BLOCKS, _T("&Blocks\tCtrl-B"),
800 _("Show block sizes")); 1149 _("Show block sizes"));
801 viewMenu->AppendCheckItem(wxID_SHOW_SKIP, _T("&Skip\tCtrl-S"), 1150 viewMenu->AppendCheckItem(wxID_SHOW_SKIP, _T("&Skip\tCtrl-S"),
802 _("Show skip bands")); 1151 _("Show skip bands"));
803 viewMenu->AppendCheckItem(wxID_SHOW_NOREF, _T("&No-Ref\tCtrl-N"), 1152 viewMenu->AppendCheckItem(wxID_SHOW_NOREF, _T("&No-Ref\tCtrl-N"),
804 _("Show no-ref bands")); 1153 _("Show no-ref bands"));
805 viewMenu->AppendCheckItem(wxID_SHOW_PADDING, _T("&Padding\tCtrl-P"), 1154 viewMenu->AppendCheckItem(wxID_SHOW_PADDING, _T("&Padding\tCtrl-P"),
806 _("Show padding area")); 1155 _("Show padding area"));
1156 viewMenu->AppendCheckItem(wxID_SHOW_BITS, _T("Bit &Accounting\tCtrl-A"),
1157 _("Show bit accounting"));
1158 viewMenu->AppendCheckItem(wxID_SHOW_DERING, _T("&Deringing\tCtrl-D"),
1159 _("Show deringing filter"));
807 viewMenu->AppendSeparator(); 1160 viewMenu->AppendSeparator();
808 viewMenu->AppendCheckItem(wxID_SHOW_Y, _T("&Y plane\tCtrl-Y"), 1161 viewMenu->AppendCheckItem(wxID_SHOW_Y, _T("&Y plane\tCtrl-Y"),
809 _("Show Y plane")); 1162 _("Show Y plane"));
810 viewMenu->AppendCheckItem(wxID_SHOW_U, _T("&U plane\tCtrl-U"), 1163 viewMenu->AppendCheckItem(wxID_SHOW_U, _T("&U plane\tCtrl-U"),
811 _("Show U plane")); 1164 _("Show U plane"));
812 viewMenu->AppendCheckItem(wxID_SHOW_V, _T("&V plane\tCtrl-V"), 1165 viewMenu->AppendCheckItem(wxID_SHOW_V, _T("&V plane\tCtrl-V"),
813 _("Show V plane")); 1166 _("Show V plane"));
814 mb->Append(viewMenu, _T("&View")); 1167 mb->Append(viewMenu, _T("&View"));
815 1168
816 playbackMenu = new wxMenu(); 1169 playbackMenu = new wxMenu();
817 playbackMenu->Append(wxID_NEXT_FRAME, _T("Next frame\t."), _("Go to next frame ")); 1170 playbackMenu->Append(wxID_NEXT_FRAME, _T("Next frame\t."),
1171 _("Go to next frame"));
1172 playbackMenu->Append(wxID_RESTART, _T("&Restart\tr"),
1173 _("Set video to frame 0"));
1174 playbackMenu->Append(wxID_GOTO_FRAME, _T("Jump to Frame\tj"),
1175 _("Go to frame number"));
818 mb->Append(playbackMenu, _T("&Playback")); 1176 mb->Append(playbackMenu, _T("&Playback"));
819 1177
820 wxMenu *helpMenu=new wxMenu(); 1178 wxMenu *helpMenu=new wxMenu();
821 helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show about dialog")); 1179 helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show about dialog"));
822 mb->Append(helpMenu, _T("&Help")); 1180 mb->Append(helpMenu, _T("&Help"));
823 1181
824 SetMenuBar(mb); 1182 SetMenuBar(mb);
825 mb->EnableTop(1, false); 1183 mb->EnableTop(1, false);
826 mb->EnableTop(2, false); 1184 mb->EnableTop(2, false);
827 1185
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 Fit(); 1221 Fit();
864 panel->render(); 1222 panel->render();
865 panel->Refresh(); 1223 panel->Refresh();
866 } 1224 }
867 } 1225 }
868 1226
869 void TestFrame::onFilter(wxCommandEvent &WXUNUSED(event)) { 1227 void TestFrame::onFilter(wxCommandEvent &WXUNUSED(event)) {
870 panel->setShowBlocks(GetMenuBar()->IsChecked(wxID_SHOW_BLOCKS)); 1228 panel->setShowBlocks(GetMenuBar()->IsChecked(wxID_SHOW_BLOCKS));
871 panel->setShowSkip(GetMenuBar()->IsChecked(wxID_SHOW_SKIP)); 1229 panel->setShowSkip(GetMenuBar()->IsChecked(wxID_SHOW_SKIP));
872 panel->setShowNoRef(GetMenuBar()->IsChecked(wxID_SHOW_NOREF)); 1230 panel->setShowNoRef(GetMenuBar()->IsChecked(wxID_SHOW_NOREF));
1231 panel->setShowDering(GetMenuBar()->IsChecked(wxID_SHOW_DERING));
873 panel->render(); 1232 panel->render();
874 panel->Refresh(false); 1233 panel->Refresh(false);
875 } 1234 }
876 1235
877 void TestFrame::onPaddingChange(wxCommandEvent &WXUNUSED(event)) { 1236 void TestFrame::onPaddingChange(wxCommandEvent &WXUNUSED(event)) {
878 panel->setShowPadding(GetMenuBar()->IsChecked(wxID_SHOW_PADDING)); 1237 panel->setShowPadding(GetMenuBar()->IsChecked(wxID_SHOW_PADDING));
879 Fit(); 1238 Fit();
880 panel->render(); 1239 panel->render();
881 panel->Refresh(); 1240 panel->Refresh();
882 } 1241 }
883 1242
1243 void TestFrame::onBitsChange(wxCommandEvent &WXUNUSED(event)) {
1244 panel->setShowBits(GetMenuBar()->IsChecked(wxID_SHOW_BITS));
1245 panel->render();
1246 panel->Refresh(false);
1247 }
1248
884 void TestFrame::onYChange(wxCommandEvent &WXUNUSED(event)) { 1249 void TestFrame::onYChange(wxCommandEvent &WXUNUSED(event)) {
885 panel->setShowPlane(GetMenuBar()->IsChecked(wxID_SHOW_Y), OD_LUMA_MASK); 1250 panel->setShowPlane(GetMenuBar()->IsChecked(wxID_SHOW_Y), OD_LUMA_MASK);
886 Fit(); 1251 Fit();
887 panel->render(); 1252 panel->render();
888 panel->Refresh(); 1253 panel->Refresh();
889 } 1254 }
890 1255
891 void TestFrame::onUChange(wxCommandEvent &WXUNUSED(event)) { 1256 void TestFrame::onUChange(wxCommandEvent &WXUNUSED(event)) {
892 panel->setShowPlane(GetMenuBar()->IsChecked(wxID_SHOW_U), OD_CB_MASK); 1257 panel->setShowPlane(GetMenuBar()->IsChecked(wxID_SHOW_U), OD_CB_MASK);
893 Fit(); 1258 Fit();
894 panel->render(); 1259 panel->render();
895 panel->Refresh(); 1260 panel->Refresh();
896 } 1261 }
897 1262
898 void TestFrame::onVChange(wxCommandEvent &WXUNUSED(event)) { 1263 void TestFrame::onVChange(wxCommandEvent &WXUNUSED(event)) {
899 panel->setShowPlane(GetMenuBar()->IsChecked(wxID_SHOW_V), OD_CR_MASK); 1264 panel->setShowPlane(GetMenuBar()->IsChecked(wxID_SHOW_V), OD_CR_MASK);
900 Fit(); 1265 Fit();
901 panel->render(); 1266 panel->render();
902 panel->Refresh(); 1267 panel->Refresh();
903 } 1268 }
904 1269
905 void TestFrame::onNextFrame(wxCommandEvent &WXUNUSED(event)) { 1270 void TestFrame::onNextFrame(wxCommandEvent &WXUNUSED(event)) {
906 panel->nextFrame(); 1271 panel->nextFrame();
907 panel->Refresh(false); 1272 panel->Refresh(false);
908 } 1273 }
909 1274
1275 void TestFrame::onGotoFrame(wxCommandEvent &WXUNUSED(event)) {
1276 panel->gotoFrame();
1277 panel->Refresh(false);
1278 }
1279
1280 void TestFrame::onRestart(wxCommandEvent &WXUNUSED(event)) {
1281 panel->restart();
1282 panel->Refresh(false);
1283 }
1284
910 void TestFrame::onAbout(wxCommandEvent& WXUNUSED(event)) { 1285 void TestFrame::onAbout(wxCommandEvent& WXUNUSED(event)) {
911 wxMessageBox(_T("This program is a bitstream analyzer for Daala."), _T("About" ), wxOK | wxICON_INFORMATION, this); 1286 wxMessageBox(_T("This program is a bitstream analyzer for Daala."), _T("About" ), wxOK | wxICON_INFORMATION, this);
912 } 1287 }
913 1288
914 bool TestFrame::open(wxString path) { 1289 bool TestFrame::open(const wxString &path) {
915 wxCharBuffer buffer = path.ToUTF8();
916 const char *filename = buffer.data();
917 panel = new TestPanel(this, path); 1290 panel = new TestPanel(this, path);
918 if (panel->open(filename)) { 1291 if (panel->open(path)) {
919 Fit(); 1292 Fit();
920 SetStatusText(_T("loaded file: ") + path); 1293 SetStatusText(_T("loaded file: ") + path);
921 fileMenu->Enable(wxID_OPEN, false); 1294 fileMenu->Enable(wxID_OPEN, false);
922 viewMenu->Enable(wxID_SHOW_PADDING, panel->hasPadding()); 1295 viewMenu->Enable(wxID_SHOW_PADDING, panel->hasPadding());
923 GetMenuBar()->EnableTop(1, true); 1296 GetMenuBar()->EnableTop(1, true);
924 GetMenuBar()->EnableTop(2, true); 1297 GetMenuBar()->EnableTop(2, true);
925 return true; 1298 return true;
926 } 1299 }
927 else { 1300 else {
928 delete panel; 1301 delete panel;
(...skipping 13 matching lines...) Expand all
942 bool TestApp::OnInit() { 1315 bool TestApp::OnInit() {
943 frame = new TestFrame(); 1316 frame = new TestFrame();
944 frame->Show(); 1317 frame->Show();
945 if (argc >= 2) { 1318 if (argc >= 2) {
946 return frame->open(wxString(argv[1])); 1319 return frame->open(wxString(argv[1]));
947 } 1320 }
948 return true; 1321 return true;
949 } 1322 }
950 1323
951 IMPLEMENT_APP(TestApp) 1324 IMPLEMENT_APP(TestApp)
LEFTRIGHT
« configure.ac ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

RSS Feeds Recent Issues | This issue
This is Rietveld