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

Delta Between Two Patch Sets: examples/analyzer.cc

Issue 1050: Add image panning to the analyzer.
Left Patch Set: Created 4 years, 3 months ago
Right Patch Set: Rebase and fix default size. 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 | « no previous file | 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 #define MIN_ZOOM (1) 299 #define MIN_ZOOM (1)
300 #define MAX_ZOOM (8) 300 #define MAX_ZOOM (8)
301 301
302 enum { 302 enum {
303 OD_LUMA_MASK = 1 << 0, 303 OD_LUMA_MASK = 1 << 0,
304 OD_CB_MASK = 1 << 1, 304 OD_CB_MASK = 1 << 1,
305 OD_CR_MASK = 1 << 2, 305 OD_CR_MASK = 1 << 2,
306 OD_ALL_MASK = OD_LUMA_MASK | OD_CB_MASK | OD_CR_MASK 306 OD_ALL_MASK = OD_LUMA_MASK | OD_CB_MASK | OD_CR_MASK
307 }; 307 };
308 308
309 class TestPanel : public wxPanel { 309 class TestPanel : public wxScrolledWindow {
310 DECLARE_EVENT_TABLE() 310 DECLARE_EVENT_TABLE()
311 private: 311 private:
312 DaalaDecoder dd; 312 DaalaDecoder dd;
313 313
314 int zoom; 314 int zoom;
315 int offset_x;
316 int offset_y;
317 unsigned char *pixels; 315 unsigned char *pixels;
318 316
319 unsigned char *bsize; 317 unsigned char *bsize;
320 unsigned int bsize_len; 318 unsigned int bsize_len;
321 int bstride; 319 int bstride;
322 bool show_blocks; 320 bool show_blocks;
323 321
324 unsigned int *flags; 322 unsigned int *flags;
325 unsigned int flags_len; 323 unsigned int flags_len;
326 int fstride; 324 int fstride;
(...skipping 25 matching lines...) Expand all
352 int getBand(int x, int y) const; 350 int getBand(int x, int y) const;
353 void computeBitsPerPixel(); 351 void computeBitsPerPixel();
354 public: 352 public:
355 TestPanel(wxWindow *parent, const wxString &path); 353 TestPanel(wxWindow *parent, const wxString &path);
356 ~TestPanel(); 354 ~TestPanel();
357 355
358 bool open(const wxString &path); 356 bool open(const wxString &path);
359 void close(); 357 void close();
360 void render(); 358 void render();
361 bool nextFrame(); 359 bool nextFrame();
360 void refresh();
361 bool gotoFrame();
362 void restart(); 362 void restart();
363 363
364 int getZoom() const; 364 int getZoom() const;
365 bool setZoom(int zoom); 365 bool setZoom(int zoom);
366 int scrollUnit() const;
366 367
367 void setShowBlocks(bool show_blocks); 368 void setShowBlocks(bool show_blocks);
368 void setShowSkip(bool show_skip); 369 void setShowSkip(bool show_skip);
369 void setShowNoRef(bool show_noref); 370 void setShowNoRef(bool show_noref);
370 void setShowPadding(bool show_padding); 371 void setShowPadding(bool show_padding);
371 void setShowBits(bool show_bits); 372 void setShowBits(bool show_bits);
372 void setShowDering(bool show_dering); 373 void setShowDering(bool show_dering);
373 void setShowPlane(bool show_plane, int mask); 374 void setShowPlane(bool show_plane, int mask);
374 375
375 bool hasPadding(); 376 bool hasPadding();
376 377
377 void onKeyDown(wxKeyEvent &event);
378 void onPaint(wxPaintEvent &event); 378 void onPaint(wxPaintEvent &event);
379 void onIdle(wxIdleEvent &event); 379 void onIdle(wxIdleEvent &event);
380 void onMouseMotion(wxMouseEvent &event); 380 void onMouseMotion(wxMouseEvent &event);
381 void onMouseLeaveWindow(wxMouseEvent &event); 381 void onMouseLeaveWindow(wxMouseEvent &event);
382 }; 382 };
383 383
384 BEGIN_EVENT_TABLE(TestPanel, wxPanel) 384 BEGIN_EVENT_TABLE(TestPanel, wxPanel)
385 EVT_KEY_DOWN(TestPanel::onKeyDown)
386 EVT_PAINT(TestPanel::onPaint) 385 EVT_PAINT(TestPanel::onPaint)
387 EVT_MOTION(TestPanel::onMouseMotion) 386 EVT_MOTION(TestPanel::onMouseMotion)
388 EVT_LEAVE_WINDOW(TestPanel::onMouseLeaveWindow) 387 EVT_LEAVE_WINDOW(TestPanel::onMouseLeaveWindow)
389 //EVT_IDLE(TestPanel::onIdle) 388 //EVT_IDLE(TestPanel::onIdle)
390 END_EVENT_TABLE() 389 END_EVENT_TABLE()
391 390
392 class TestFrame : public wxFrame { 391 class TestFrame : public wxFrame {
393 DECLARE_EVENT_TABLE() 392 DECLARE_EVENT_TABLE()
394 private: 393 private:
395 TestPanel *panel; 394 TestPanel *panel;
396 wxMenu *fileMenu; 395 wxMenu *fileMenu;
397 wxMenu *viewMenu; 396 wxMenu *viewMenu;
398 wxMenu *playbackMenu; 397 wxMenu *playbackMenu;
399 public: 398 public:
400 TestFrame(); 399 TestFrame();
401 400
402 void onOpen(wxCommandEvent &event); 401 void onOpen(wxCommandEvent &event);
403 void onClose(wxCommandEvent &event); 402 void onClose(wxCommandEvent &event);
404 void onQuit(wxCommandEvent &event); 403 void onQuit(wxCommandEvent &event);
405 void onZoomIn(wxCommandEvent &event); 404 void onZoomIn(wxCommandEvent &event);
406 void onZoomOut(wxCommandEvent &event); 405 void onZoomOut(wxCommandEvent &event);
407 void onFilter(wxCommandEvent &event); 406 void onFilter(wxCommandEvent &event);
408 void onPaddingChange(wxCommandEvent &event); 407 void onPaddingChange(wxCommandEvent &event);
409 void onBitsChange(wxCommandEvent &event); 408 void onBitsChange(wxCommandEvent &event);
410 void onYChange(wxCommandEvent &event); 409 void onYChange(wxCommandEvent &event);
411 void onUChange(wxCommandEvent &event); 410 void onUChange(wxCommandEvent &event);
412 void onVChange(wxCommandEvent &event); 411 void onVChange(wxCommandEvent &event);
413 void onNextFrame(wxCommandEvent &event); 412 void onNextFrame(wxCommandEvent &event);
413 void onGotoFrame(wxCommandEvent &event);
414 void onRestart(wxCommandEvent &event); 414 void onRestart(wxCommandEvent &event);
415 void onAbout(wxCommandEvent &event); 415 void onAbout(wxCommandEvent &event);
416 416
417 bool open(const wxString &path); 417 bool open(const wxString &path);
418 }; 418 };
419 419
420 enum { 420 enum {
421 wxID_SHOW_BLOCKS = 6000, 421 wxID_SHOW_BLOCKS = 6000,
422 wxID_SHOW_SKIP, 422 wxID_SHOW_SKIP,
423 wxID_SHOW_NOREF, 423 wxID_SHOW_NOREF,
424 wxID_SHOW_PADDING, 424 wxID_SHOW_PADDING,
425 wxID_SHOW_BITS, 425 wxID_SHOW_BITS,
426 wxID_SHOW_DERING, 426 wxID_SHOW_DERING,
427 wxID_SHOW_Y, 427 wxID_SHOW_Y,
428 wxID_SHOW_U, 428 wxID_SHOW_U,
429 wxID_SHOW_V, 429 wxID_SHOW_V,
430 wxID_NEXT_FRAME, 430 wxID_NEXT_FRAME,
431 wxID_GOTO_FRAME,
431 wxID_RESTART 432 wxID_RESTART
432 }; 433 };
433 434
434 BEGIN_EVENT_TABLE(TestFrame, wxFrame) 435 BEGIN_EVENT_TABLE(TestFrame, wxFrame)
435 EVT_MENU(wxID_OPEN, TestFrame::onOpen) 436 EVT_MENU(wxID_OPEN, TestFrame::onOpen)
436 EVT_MENU(wxID_CLOSE, TestFrame::onClose) 437 EVT_MENU(wxID_CLOSE, TestFrame::onClose)
437 EVT_MENU(wxID_EXIT, TestFrame::onQuit) 438 EVT_MENU(wxID_EXIT, TestFrame::onQuit)
438 EVT_MENU(wxID_ZOOM_IN, TestFrame::onZoomIn) 439 EVT_MENU(wxID_ZOOM_IN, TestFrame::onZoomIn)
439 EVT_MENU(wxID_ZOOM_OUT, TestFrame::onZoomOut) 440 EVT_MENU(wxID_ZOOM_OUT, TestFrame::onZoomOut)
440 EVT_MENU(wxID_SHOW_BLOCKS, TestFrame::onFilter) 441 EVT_MENU(wxID_SHOW_BLOCKS, TestFrame::onFilter)
441 EVT_MENU(wxID_SHOW_SKIP, TestFrame::onFilter) 442 EVT_MENU(wxID_SHOW_SKIP, TestFrame::onFilter)
442 EVT_MENU(wxID_SHOW_NOREF, TestFrame::onFilter) 443 EVT_MENU(wxID_SHOW_NOREF, TestFrame::onFilter)
443 EVT_MENU(wxID_SHOW_PADDING, TestFrame::onPaddingChange) 444 EVT_MENU(wxID_SHOW_PADDING, TestFrame::onPaddingChange)
444 EVT_MENU(wxID_SHOW_BITS, TestFrame::onBitsChange) 445 EVT_MENU(wxID_SHOW_BITS, TestFrame::onBitsChange)
445 EVT_MENU(wxID_SHOW_DERING, TestFrame::onFilter) 446 EVT_MENU(wxID_SHOW_DERING, TestFrame::onFilter)
446 EVT_MENU(wxID_SHOW_Y, TestFrame::onYChange) 447 EVT_MENU(wxID_SHOW_Y, TestFrame::onYChange)
447 EVT_MENU(wxID_SHOW_U, TestFrame::onUChange) 448 EVT_MENU(wxID_SHOW_U, TestFrame::onUChange)
448 EVT_MENU(wxID_SHOW_V, TestFrame::onVChange) 449 EVT_MENU(wxID_SHOW_V, TestFrame::onVChange)
449 EVT_MENU(wxID_NEXT_FRAME, TestFrame::onNextFrame) 450 EVT_MENU(wxID_NEXT_FRAME, TestFrame::onNextFrame)
451 EVT_MENU(wxID_GOTO_FRAME, TestFrame::onGotoFrame)
450 EVT_MENU(wxID_RESTART, TestFrame::onRestart) 452 EVT_MENU(wxID_RESTART, TestFrame::onRestart)
451 EVT_MENU(wxID_ABOUT, TestFrame::onAbout) 453 EVT_MENU(wxID_ABOUT, TestFrame::onAbout)
452 END_EVENT_TABLE() 454 END_EVENT_TABLE()
453 455
454 TestPanel::TestPanel(wxWindow *parent, const wxString &path) : wxPanel(parent), 456 TestPanel::TestPanel(wxWindow *parent, const wxString &path) : wxScrolledWindow( parent),
455 pixels(NULL), zoom(0), bsize(NULL), bsize_len(0), show_blocks(false), 457 pixels(NULL), zoom(0), bsize(NULL), bsize_len(0), show_blocks(false),
456 flags(NULL), flags_len(0), show_skip(false), show_noref(false), 458 flags(NULL), flags_len(0), show_skip(false), show_noref(false),
457 show_padding(false), show_dering(false), acct(NULL), show_bits(false), 459 show_padding(false), show_dering(false), acct(NULL), show_bits(false),
458 bpp_q3(NULL), dering(NULL), dering_len(0), plane_mask(OD_ALL_MASK), 460 bpp_q3(NULL), dering(NULL), dering_len(0), plane_mask(OD_ALL_MASK),
459 path(path), 461 path(path) {
460 offset_x(0),
461 offset_y(0) {
462 } 462 }
463 463
464 TestPanel::~TestPanel() { 464 TestPanel::~TestPanel() {
465 close(); 465 close();
466 } 466 }
467 467
468 bool TestPanel::open(const wxString &path) { 468 bool TestPanel::open(const wxString &path) {
469 if (!dd.open(path)) { 469 if (!dd.open(path)) {
470 return false; 470 return false;
471 } 471 }
472 SetSize(dd.getWidth(), dd.getHeight());
472 if (!setZoom(MIN_ZOOM)) { 473 if (!setZoom(MIN_ZOOM)) {
473 return false; 474 return false;
474 } 475 }
475 int nhsb = dd.getFrameWidth() >> OD_LOG_BSIZE0 + OD_NBSIZES - 1; 476 int nhsb = dd.getFrameWidth() >> OD_LOG_BSIZE0 + OD_NBSIZES - 1;
476 int nvsb = dd.getFrameHeight() >> OD_LOG_BSIZE0 + OD_NBSIZES - 1; 477 int nvsb = dd.getFrameHeight() >> OD_LOG_BSIZE0 + OD_NBSIZES - 1;
477 bsize_len = sizeof(*bsize)*nhsb*4*nvsb*4; 478 bsize_len = sizeof(*bsize)*nhsb*4*nvsb*4;
478 bsize = (unsigned char *)malloc(bsize_len); 479 bsize = (unsigned char *)malloc(bsize_len);
479 if (bsize == NULL) { 480 if (bsize == NULL) {
480 bsize_len = 0; 481 bsize_len = 0;
481 close(); 482 close();
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 cbval = 255; 680 cbval = 255;
680 crval = 255 - (int64_t)(127*bpp); 681 crval = 255 - (int64_t)(127*bpp);
681 } 682 }
682 #endif 683 #endif
683 } 684 }
684 if (show_dering) { 685 if (show_dering) {
685 int sbx; 686 int sbx;
686 int sby; 687 int sby;
687 sbx = i >> OD_LOG_BSIZE0 + OD_NBSIZES - 1; 688 sbx = i >> OD_LOG_BSIZE0 + OD_NBSIZES - 1;
688 sby = j >> OD_LOG_BSIZE0 + OD_NBSIZES - 1; 689 sby = j >> OD_LOG_BSIZE0 + OD_NBSIZES - 1;
689 if (!dering[sby*nhsb + sbx]) { 690 if (dering[sby*nhsb + sbx]) {
690 yval = 0; 691 yval = 0;
691 } 692 }
692 } 693 }
693 if (show_blocks) { 694 if (show_blocks) {
694 unsigned char d = OD_BLOCK_SIZE4x4(bsize, bstride, i >> 2, j >> 2); 695 unsigned char d = OD_BLOCK_SIZE4x4(bsize, bstride, i >> 2, j >> 2);
695 int mask = (1 << d + OD_LOG_BSIZE0) - 1; 696 int mask = (1 << d + OD_LOG_BSIZE0) - 1;
696 if (!(i & mask) || !(j & mask)) { 697 if (!(i & mask) || !(j & mask)) {
697 yval = block_edge_luma(yval); 698 yval = block_edge_luma(yval);
698 cbval = (cbval + 128) >> 1; 699 cbval = (cbval + 128) >> 1;
699 crval = (crval + 128) >> 1; 700 crval = (crval + 128) >> 1;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 cb_row += dc & cb_stride; 743 cb_row += dc & cb_stride;
743 cr_row += dc & cr_stride; 744 cr_row += dc & cr_stride;
744 p_row += zoom*p_stride; 745 p_row += zoom*p_stride;
745 } 746 }
746 } 747 }
747 748
748 int TestPanel::getZoom() const { 749 int TestPanel::getZoom() const {
749 return zoom; 750 return zoom;
750 } 751 }
751 752
753 int TestPanel::scrollUnit() const {
754 return zoom*8;
755 }
756
752 bool TestPanel::updateDisplaySize() { 757 bool TestPanel::updateDisplaySize() {
753 unsigned char *p = 758 unsigned char *p =
754 (unsigned char *)malloc(sizeof(*p)*3*getDisplayWidth()*getDisplayHeight()); 759 (unsigned char *)malloc(sizeof(*p)*3*getDisplayWidth()*getDisplayHeight());
755 if (p == NULL) { 760 if (p == NULL) {
756 return false; 761 return false;
757 } 762 }
758 free(pixels); 763 free(pixels);
759 pixels = p; 764 pixels = p;
760 SetSize(getDisplayWidth(), getDisplayHeight()); 765 int sx, sy;
766 GetViewStart(&sx, &sy);
767 SetScrollbars(scrollUnit(), scrollUnit(),
768 getDisplayWidth()/scrollUnit(), getDisplayHeight()/scrollUnit(), sx, sy);
761 return true; 769 return true;
762 } 770 }
763 771
764 bool TestPanel::setZoom(int z) { 772 bool TestPanel::setZoom(int z) {
765 if (z <= MAX_ZOOM && z >= MIN_ZOOM && zoom != z) { 773 if (z <= MAX_ZOOM && z >= MIN_ZOOM && zoom != z) {
766 int old_zoom = zoom; 774 int old_zoom = zoom;
767 zoom = z; 775 zoom = z;
768 if (!updateDisplaySize()) { 776 if (!updateDisplaySize()) {
769 zoom = old_zoom; 777 zoom = old_zoom;
770 return false; 778 return false;
(...skipping 30 matching lines...) Expand all
801 void TestPanel::setShowPlane(bool show_plane, int mask) { 809 void TestPanel::setShowPlane(bool show_plane, int mask) {
802 if (show_plane) { 810 if (show_plane) {
803 plane_mask |= mask; 811 plane_mask |= mask;
804 } else { 812 } else {
805 plane_mask &= ~mask; 813 plane_mask &= ~mask;
806 } 814 }
807 } 815 }
808 816
809 bool TestPanel::hasPadding() { 817 bool TestPanel::hasPadding() {
810 return dd.getFrameWidth() > dd.getWidth() || 818 return dd.getFrameWidth() > dd.getWidth() ||
811 dd.getFrameHeight() > dd.getHeight(); 819 dd.getFrameHeight() > dd.getHeight();
812 } 820 }
813 821
814 void TestPanel::setShowNoRef(bool show_noref) { 822 void TestPanel::setShowNoRef(bool show_noref) {
815 this->show_noref = show_noref; 823 this->show_noref = show_noref;
816 } 824 }
817 825
818 void TestPanel::computeBitsPerPixel() { 826 void TestPanel::computeBitsPerPixel() {
819 int i, j; 827 int i, j;
820 double bpp_total; 828 double bpp_total;
821 for (j = 0; j < dd.getFrameHeight(); j++) { 829 for (j = 0; j < dd.getFrameHeight(); j++) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 } 912 }
905 913
906 } 914 }
907 break; 915 break;
908 } 916 }
909 } 917 }
910 } 918 }
911 fprintf(stderr, "nb_syms = %i\n", acct->nb_syms); 919 fprintf(stderr, "nb_syms = %i\n", acct->nb_syms);
912 fprintf(stderr, "bpp_total = %lf\n", bpp_total); 920 fprintf(stderr, "bpp_total = %lf\n", bpp_total);
913 } 921 }
914 922 void TestPanel::refresh() {
923 computeBitsPerPixel();
924 render();
925 ((TestFrame *)GetParent())->SetTitle(path +
926 wxString::Format(wxT(" (%d,%d) Frame %d - Daala Stream Analyzer"),
927 dd.getWidth(), dd.getHeight(), dd.getRunningFrameCount()-1));
928 }
915 bool TestPanel::nextFrame() { 929 bool TestPanel::nextFrame() {
916 if (dd.step()) { 930 if (dd.step()) {
917 /* For now just compute the unfiltered bits per pixel. */ 931 /* For now just compute the unfiltered bits per pixel. */
918 computeBitsPerPixel(); 932 refresh();
919 render();
920 ((TestFrame *)GetParent())->SetTitle(path +
921 wxString::Format(wxT(" (%d,%d) Frame %d - Daala Stream Analyzer"),
922 dd.getWidth(), dd.getHeight(), dd.getRunningFrameCount()-1));
923 return true; 933 return true;
924 } 934 }
925 return false; 935 return false;
936 }
937
938 bool TestPanel::gotoFrame() {
939 bool toReturn;
940 int nframe;
941 wxTextEntryDialog dlg(this, _T("Jump to which frame?"));
942 dlg.SetTextValidator(wxFILTER_NUMERIC);
943 if (dlg.ShowModal() == wxID_OK) {
944 nframe = wxAtoi(dlg.GetValue());
945 }
946 else {
947 return false;
948 }
949 if (nframe < dd.frame) {
950 restart();
951 }
952 if(nframe <= 0) {
953 return true;
954 }
955 if(nframe == dd.frame+1) {
956 return nextFrame();
957 }
958 while (nframe >= dd.frame) {
959 toReturn = dd.step();
960 if (!toReturn) {
961 wxMessageBox(_T("Error: Video doesn't have that many frames"));
962 restart();
963 return false;
964 }
965 }
966 refresh();
967 return toReturn;
926 } 968 }
927 969
928 void TestPanel::restart() { 970 void TestPanel::restart() {
929 dd.restart(); 971 dd.restart();
930 dd.setBlockSizeBuffer(bsize, bsize_len); 972 dd.setBlockSizeBuffer(bsize, bsize_len);
931 dd.setBandFlagsBuffer(flags, flags_len); 973 dd.setBandFlagsBuffer(flags, flags_len);
932 dd.setAccountingEnabled(true); 974 dd.setAccountingEnabled(true);
933 dd.getAccountingStruct(&acct); 975 dd.getAccountingStruct(&acct);
934 dd.setDeringFlagsBuffer(dering, dering_len); 976 dd.setDeringFlagsBuffer(dering, dering_len);
935 nextFrame(); 977 nextFrame();
936 } 978 }
937 979
938 void TestPanel::onKeyDown(wxKeyEvent &event) {
939 switch (event.GetKeyCode()) {
940 case '.' : {
941 nextFrame();
942 Refresh(false);
943 break;
944 }
945 /* Catches 'r' and 'R' */
946 case 'R' : {
947 restart();
948 Refresh(false);
949 break;
950 }
951 case WXK_LEFT : {
952 offset_x += 1;
953 Refresh(false);
954 break;
955 }
956 case WXK_RIGHT : {
957 offset_x -= 1;
958 Refresh(false);
959 break;
960 }
961 case WXK_UP : {
962 offset_y += 1;
963 Refresh(false);
964 break;
965 }
966 case WXK_DOWN : {
967 offset_y -= 1;
968 Refresh(false);
969 break;
970 }
971 }
972 }
973
974 void TestPanel::onMouseMotion(wxMouseEvent& event) { 980 void TestPanel::onMouseMotion(wxMouseEvent& event) {
975 const wxPoint pt = wxGetMousePosition(); 981 const wxPoint pt = wxGetMousePosition();
976 int mouse_x = pt.x - this->GetScreenPosition().x; 982 int mouse_x = pt.x - this->GetScreenPosition().x;
977 int mouse_y = pt.y - this->GetScreenPosition().y; 983 int mouse_y = pt.y - this->GetScreenPosition().y;
978 TestFrame *parent = static_cast<TestFrame*>(GetParent()); 984 TestFrame *parent = static_cast<TestFrame*>(GetParent());
979 int row = mouse_y/zoom; 985 int sx, sy;
980 int col = mouse_x/zoom; 986 GetViewStart(&sx, &sy);
987 /* Offset row / col by scroll position. */
988 int col = (mouse_x + sx*scrollUnit())/zoom;
989 int row = (mouse_y + sy*scrollUnit())/zoom;
981 if (row >= 0 && col >= 0 && row < getDecodeHeight() 990 if (row >= 0 && col >= 0 && row < getDecodeHeight()
982 && col < getDecodeWidth()) { 991 && col < getDecodeWidth()) {
983 const od_img_plane *planes = dd.img.planes; 992 const od_img_plane *planes = dd.img.planes;
984 /* Assume both chroma planes are decimated the same */ 993 /* Assume both chroma planes are decimated the same */
985 int xdec = planes[1].xdec; 994 int xdec = planes[1].xdec;
986 int ydec = planes[1].ydec; 995 int ydec = planes[1].ydec;
987 int cb_stride = planes[1].ystride; 996 int cb_stride = planes[1].ystride;
988 int cr_stride = planes[2].ystride; 997 int cr_stride = planes[2].ystride;
989 ogg_int64_t y = planes[0].data[planes[0].ystride*row + col]; 998 ogg_int64_t y = planes[0].data[planes[0].ystride*row + col];
990 ogg_int64_t cb = planes[1].data[cb_stride*(row >> ydec) + (col >> xdec)]; 999 ogg_int64_t cb = planes[1].data[cb_stride*(row >> ydec) + (col >> xdec)];
991 ogg_int64_t cr = planes[2].data[cr_stride*(row >> ydec) + (col >> xdec)]; 1000 ogg_int64_t cr = planes[2].data[cr_stride*(row >> ydec) + (col >> xdec)];
992 parent->SetStatusText(wxString::Format(wxT("Y:%lld,U:%lld,V:%lld"), 1001 parent->SetStatusText(wxString::Format(wxT("Y:%lld,U:%lld,V:%lld"),
993 y, cb, cr), 1); 1002 y, cb, cr), 1);
994 } else { 1003 } else {
995 parent->SetStatusText(wxString::Format(wxT("")), 1); 1004 parent->SetStatusText(wxString::Format(wxT("")), 1);
996 } 1005 }
997 parent->SetStatusText(wxString::Format(wxT("X:%d,Y:%d"), 1006 parent->SetStatusText(wxString::Format(wxT("X:%d,Y:%d"),
998 col, row), 2); 1007 col, row), 2);
999 } 1008 }
1000 1009
1001 void TestPanel::onMouseLeaveWindow(wxMouseEvent& event) { 1010 void TestPanel::onMouseLeaveWindow(wxMouseEvent& event) {
1002 TestFrame *parent = static_cast<TestFrame*>(GetParent()); 1011 TestFrame *parent = static_cast<TestFrame*>(GetParent());
1003 parent->SetStatusText(wxString::Format(wxT("")), 1); 1012 parent->SetStatusText(wxString::Format(wxT("")), 1);
1004 } 1013 }
1005 1014
1006 void TestPanel::onPaint(wxPaintEvent &) { 1015 void TestPanel::onPaint(wxPaintEvent &) {
1016 int sx, sy;
1017 GetViewStart(&sx, &sy);
1007 wxBitmap bmp(wxImage(getDisplayWidth(), getDisplayHeight(), pixels, true)); 1018 wxBitmap bmp(wxImage(getDisplayWidth(), getDisplayHeight(), pixels, true));
1008 wxBufferedPaintDC dc(this); 1019 wxBufferedPaintDC dc(this);
1009 dc.SetBackgroundMode(wxSOLID); 1020 dc.SetBackgroundMode(wxSOLID);
1010 dc.SetBackground(wxColor(0,0,0)); 1021 dc.SetBackground(wxColor(0,0,0));
1011 dc.Clear(); 1022 dc.Clear();
1012 dc.DrawBitmap(bmp, offset_x*zoom*OD_BSIZE_MAX, offset_y*zoom*OD_BSIZE_MAX); 1023 dc.DrawBitmap(bmp, -sx*scrollUnit(), -sy*scrollUnit());
1013 } 1024 }
1014 1025
1015 void TestPanel::onIdle(wxIdleEvent &) { 1026 void TestPanel::onIdle(wxIdleEvent &) {
1016 nextFrame(); 1027 nextFrame();
1017 Refresh(false); 1028 Refresh(false);
1018 /*wxMilliSleep(input.video_fps_n*1000/input.video_fps_n);*/ 1029 /*wxMilliSleep(input.video_fps_n*1000/input.video_fps_n);*/
1019 } 1030 }
1020 1031
1021 TestFrame::TestFrame() : wxFrame(NULL, wxID_ANY, _T("Daala Stream Analyzer"), 1032 TestFrame::TestFrame() : wxFrame(NULL, wxID_ANY, _T("Daala Stream Analyzer"),
1022 wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE), panel(NULL) { 1033 wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE), panel(NULL) {
(...skipping 30 matching lines...) Expand all
1053 _("Show U plane")); 1064 _("Show U plane"));
1054 viewMenu->AppendCheckItem(wxID_SHOW_V, _T("&V plane\tCtrl-V"), 1065 viewMenu->AppendCheckItem(wxID_SHOW_V, _T("&V plane\tCtrl-V"),
1055 _("Show V plane")); 1066 _("Show V plane"));
1056 mb->Append(viewMenu, _T("&View")); 1067 mb->Append(viewMenu, _T("&View"));
1057 1068
1058 playbackMenu = new wxMenu(); 1069 playbackMenu = new wxMenu();
1059 playbackMenu->Append(wxID_NEXT_FRAME, _T("Next frame\t."), 1070 playbackMenu->Append(wxID_NEXT_FRAME, _T("Next frame\t."),
1060 _("Go to next frame")); 1071 _("Go to next frame"));
1061 playbackMenu->Append(wxID_RESTART, _T("&Restart\tr"), 1072 playbackMenu->Append(wxID_RESTART, _T("&Restart\tr"),
1062 _("Set video to frame 0")); 1073 _("Set video to frame 0"));
1074 playbackMenu->Append(wxID_GOTO_FRAME, _T("Jump to Frame\tj"),
1075 _("Go to frame number"));
1063 mb->Append(playbackMenu, _T("&Playback")); 1076 mb->Append(playbackMenu, _T("&Playback"));
1064 1077
1065 wxMenu *helpMenu=new wxMenu(); 1078 wxMenu *helpMenu=new wxMenu();
1066 helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show about dialog")); 1079 helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show about dialog"));
1067 mb->Append(helpMenu, _T("&Help")); 1080 mb->Append(helpMenu, _T("&Help"));
1068 1081
1069 SetMenuBar(mb); 1082 SetMenuBar(mb);
1070 mb->EnableTop(1, false); 1083 mb->EnableTop(1, false);
1071 mb->EnableTop(2, false); 1084 mb->EnableTop(2, false);
1072 1085
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 1162
1150 void TestFrame::onVChange(wxCommandEvent &WXUNUSED(event)) { 1163 void TestFrame::onVChange(wxCommandEvent &WXUNUSED(event)) {
1151 panel->setShowPlane(GetMenuBar()->IsChecked(wxID_SHOW_V), OD_CR_MASK); 1164 panel->setShowPlane(GetMenuBar()->IsChecked(wxID_SHOW_V), OD_CR_MASK);
1152 Fit(); 1165 Fit();
1153 panel->render(); 1166 panel->render();
1154 panel->Refresh(); 1167 panel->Refresh();
1155 } 1168 }
1156 1169
1157 void TestFrame::onNextFrame(wxCommandEvent &WXUNUSED(event)) { 1170 void TestFrame::onNextFrame(wxCommandEvent &WXUNUSED(event)) {
1158 panel->nextFrame(); 1171 panel->nextFrame();
1172 panel->Refresh(false);
1173 }
1174
1175 void TestFrame::onGotoFrame(wxCommandEvent &WXUNUSED(event)) {
1176 panel->gotoFrame();
1159 panel->Refresh(false); 1177 panel->Refresh(false);
1160 } 1178 }
1161 1179
1162 void TestFrame::onRestart(wxCommandEvent &WXUNUSED(event)) { 1180 void TestFrame::onRestart(wxCommandEvent &WXUNUSED(event)) {
1163 panel->restart(); 1181 panel->restart();
1164 panel->Refresh(false); 1182 panel->Refresh(false);
1165 } 1183 }
1166 1184
1167 void TestFrame::onAbout(wxCommandEvent& WXUNUSED(event)) { 1185 void TestFrame::onAbout(wxCommandEvent& WXUNUSED(event)) {
1168 wxMessageBox(_T("This program is a bitstream analyzer for Daala."), _T("About" ), wxOK | wxICON_INFORMATION, this); 1186 wxMessageBox(_T("This program is a bitstream analyzer for Daala."), _T("About" ), wxOK | wxICON_INFORMATION, this);
(...skipping 28 matching lines...) Expand all
1197 bool TestApp::OnInit() { 1215 bool TestApp::OnInit() {
1198 frame = new TestFrame(); 1216 frame = new TestFrame();
1199 frame->Show(); 1217 frame->Show();
1200 if (argc >= 2) { 1218 if (argc >= 2) {
1201 return frame->open(wxString(argv[1])); 1219 return frame->open(wxString(argv[1]));
1202 } 1220 }
1203 return true; 1221 return true;
1204 } 1222 }
1205 1223
1206 IMPLEMENT_APP(TestApp) 1224 IMPLEMENT_APP(TestApp)
LEFTRIGHT
« no previous file | 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